[Maverick] username mismatch with quickly share

Bug #640689 reported by Kristian Kißling
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Quickly
Fix Released
Undecided
Unassigned
launchpadlib
Invalid
Undecided
Unassigned
quickly (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Quickly 0.6
  Python interpreter: /usr/bin/python 2.6.6
  Python standard library: /usr/lib/python2.6

I tried to upload my test project with
$ quickly share

Didn't work:
"Konnte Launchpad für quickly nicht einrichten ; Stored username None and specified username kkissling mismatch."

I have no idea, what that means...

Related branches

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Thanks for using Quickly and reporting this bug.
Well, I don't know about German language :)

Can you please run:
$ LANG=C quickly share

and paste the output there?

Then, again:
$ LANG=C quickly share --verbose

and paste the output there too.

Changed in quickly:
status: New → Incomplete
Revision history for this message
Kristian Kißling (kkissling) wrote :

Thanks for your quick answer, awesome :)

kkissling@kkissling-desktop:~/superapp$ LANG=C quickly share
Get Launchpad Settings
Initial Launchpad binding. You must choose "Change Anything"
The authorization page:
   (https://edge.launchpad.net/+authorize-token?oauth_token=nvPpbZ0tN2lG7bCZbT52)
should be opening in your browser. After you have authorized
this program to access Launchpad on your behalf you should come
back here and press <Enter> to finish the authentication process.

Couldn't setup Launchpad for quickly ; Stored username None and specified username kkissling mismatch.
ERROR: share command failed
Aborting
kkissling@kkissling-desktop:~/superapp$ LANG=C quickly share --verbose
...
Couldn't setup Launchpad for quickly ; Stored username None and specified username kkissling mismatch.
ERROR: share command failed
Aborting

Btw: Launchpad wants me to authorize quickly all over again every time I use "quickly share", that looks strange to me.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Did the page in link is opening in your browser?

Normally, you should see a page opening in the browser, then, click on "Change Anything", waiting for it to be accepted (it should write something like "almost finished".

Then, you just press Enter on your command line to finish authentification.

Revision history for this message
Kristian Kißling (kkissling) wrote :

It works exactly like that. But after pressing [Enter] I get the above mentioned error.

And I have to click on "Change Anything" everytime I call "quickly share". Therefor Quickly has about ten entries in "Authorized applications", one should be sufficient, I guess.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

The issue is due to launchpadlib then, I'm re-affecting to this component if developer can gives a deeper look then.

affects: quickly → launchpadlib
Changed in launchpadlib:
status: Incomplete → Confirmed
Revision history for this message
Kristian Kißling (kkissling) wrote :

Thanks for the effort!

Revision history for this message
Kristian Kißling (kkissling) wrote :

Any guesses already what this is about?

Revision history for this message
Martin Pool (mbp) wrote :

Can we get a traceback?

Revision history for this message
Leonard Richardson (leonardr) wrote :

Here's the relevant code from Quickly: http://pastebin.ubuntu.com/503923/

This code looks like it was written against a really old version of launchpadlib, and that's probably irrelevant to this bug, but I'm not sure. In this comment I'll spell out some improvements you can make. Cleaning up the launchpadlib code will make it more clear what the problem is, and it will also improve your user experience.

1. Constants. Your LAUNCHPAD_URL can be replaced with launchpadlib.uri.LPNET_WEB_ROOT. Your LAUNCHPAD_STAGING_URL can be replaced with launchpadlib.uri.STAGING_WEB_ROOT.

You should import EDGE_SERVICE_ROOT and STAGING_SERVICE_ROOT from launchpadlib.uri, because the ones in launchpadlib.launchpad are deprecated. Or you can just use "edge" and "staging"--the values you have now for lp_server.

2. I strongly recommend you use Launchpad.login_with() instead of Launchpad.get_token_and_login(). You'll save a lot of code, and the credentials will be more secure (right now you're creating the credential directory in an insecure way). And once login_with() stores credentials in the GNOME keyring, you'll automatically start taking advantage of that feature.

I also hope that login_with() will soon authorize the entire GNOME desktop at once, which will mean that you may not have to authorize a separate token for Quickly at all. Of course, the current plan is that you will have to authorize a separate Quickly token for uploading GPG keys, but you shouldn't have to authorize a token on startup.

3. Access level. You print out a message to the user telling them 'You must choose "Change Anything"'. If you pass allow_access_levels=['READ_PRIVATE'] to login_with (or get_token_and_login), then when the browser window pops up, Launchpad will only present two options: "Change Anything" and "Deny Access". The options that won't work for Quickly won't even show up.

Later versions of launchpadlib will hopefully authorize the entire GNOME desktop at once, and then it won't matter what you pass in for allow_access_levels. But for current versions of launchpadlib, passing in allow_access_levels=['READ_PRIVATE'] will greatly improve the user experience.

If you have questions about compatibility with old versions of launchpadlib, let me know and I'll look into exactly how old these features are. But I'm pretty sure they're all at least 6 months old.

Revision history for this message
Leonard Richardson (leonardr) wrote :

OK, now on to the actual error. The error message "Stored username None and specified username kkissling mismatch." comes from an old implementation of Quickly's bzr_set_login:

    # if no bzr launchpad-login set, set it now !
    if launchpad_name:
        from bzrlib.plugins.launchpad import account
        stored_username = account.get_lp_login()
        if stored_username is not None:
            # No account set yet
            launchpad_name = launchpad_name.lower()
            account.check_lp_login(launchpad_name)
            account.set_lp_login(launchpad_name)
        elif stored_username != launchpad_name:
            return (1,
                _("Stored username %s and specified username %s mismatch." % (
                    stored_username, launchpad_name)))

This code was just reverted (rev 540, on September 28, "Merge bzr internal API use reverts"), and the current implementation invokes bzr shell commands.

I've never seen this code before, but it looks wrong, in a way that would explain why it was reverted and why this problem is happening. It seems like that if statement ought to be "if stored_username is None", not "if stored_username is not None". With the code as it is, if you've never set your bzr Launchpad login name, you'll get an error that None doesn't match the login name you want to set.

But, that code is only run in an except clause, when something goes wrong creating the Launchpad object. Why is it going wrong every time? This could be a problem with launchpadlib, a problem with the Launchpad server itself, or a problem with the Quickly code that reads the credentials file. (This is why I suggested that switching to login_with() might solve the problem.) Whatever it is, getting a new credential doesn't solve the problem, and so the next time the user starts up Quickly, the exception happens again and they have to get *another* credential. And because of the 'if stored_username is not None' problem, Quickly exits before the user can do anything.

To find out exactly what the problem is, hack the code to re-raise the underlying error:

except (IOError, HTTPError), e:
    raise e
    if interactive:
        ...

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

ok, I just had a quick look, I'll try to get some time on Monday to convert that.

Indeed, this part of Quickly has been written in May 2009, where we didn't have all this facility to use the new and simplified launchpadlib api.

if mterry has some time to have a look at it before, I wouldn't mind :-)

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

yeah, the whole branch contributed by jelmer had a lot of unexpected issues, different code path and crashers. That's why we took the decision to revert it in trunk and we will do an new Quickly release next week for maverick.

I'll before merging to trunk, propose to you the new facility to see if we use it right or not.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

@Kristian: can you please try from trunk, to see if the revert fixes partially your issue?

you just have to:
$ bzr branch lp:quickly
$ PATH=<path/to/quickly>/bin:$PATH
then:
$ quickly --version
should show you some paths for templates and librairies from trunk (not system ones)
$ cd <your_project>
$ quickly share

thanks! :)

Revision history for this message
Kristian Kißling (kkissling) wrote :

@Didier: of course, as soon as I find the machine/installation I tested that with :)

Revision history for this message
James Westby (james-w) wrote : Re: [Bug 640689] Re: [Maverick] username mismatch with quickly share

On Fri, 01 Oct 2010 14:28:45 -0000, Leonard Richardson <email address hidden> wrote:
> 3. Access level. You print out a message to the user telling them 'You
> must choose "Change Anything"'. If you pass
> allow_access_levels=['READ_PRIVATE'] to login_with (or
> get_token_and_login), then when the browser window pops up, Launchpad
> will only present two options: "Change Anything" and "Deny Access". The
> options that won't work for Quickly won't even show up.
>
> Later versions of launchpadlib will hopefully authorize the entire GNOME
> desktop at once, and then it won't matter what you pass in for
> allow_access_levels. But for current versions of launchpadlib, passing
> in allow_access_levels=['READ_PRIVATE'] will greatly improve the user
> experience.

WRITE_PRIVATE no?

Thanks,

James

Revision history for this message
Kristian Kißling (kkissling) wrote :

Now I got this:

$ quickly --version
Quickly 0.6
  Python interpreter: /usr/bin/python 2.6.6
  Python standard library: /usr/lib/python2.6

  Quickly used library: /home/redaktion/quickly/quickly
  Quickly data path: /home/redaktion/quickly/data
  Quickly detected template directories:
          /home/redaktion/quickly/data/templates/
[...]

and then...

redaktion@redaktionsrechner:~/superapp$ LANG=C quickly share
Get Launchpad Settings
Launchpad connection is ok
It seems you don't have a gpg key on your computer. Do you want to create one (this may take a while)? y/[n]: y
Traceback (most recent call last):
  File "/home/redaktion/quickly/data/templates/ubuntu-application/share.py", line 107, in <module>
    keyid = quicklyutils.get_right_gpg_key_id(launchpad)
  File "/home/redaktion/quickly/data/templates/ubuntu-application/internal/quicklyutils.py", line 354, in get_right_gpg_key_id
    launchpad.me.display_name, prefered_emails[0])]
  File "/home/redaktion/quickly/data/templates/ubuntu-application/internal/quicklyutils.py", line 298, in create_gpg_key
    result, err = gpg_instance.communicate(key_generate)
  File "/usr/lib/python2.6/subprocess.py", line 691, in communicate
    return self._communicate(input)
  File "/usr/lib/python2.6/subprocess.py", line 1222, in _communicate
    bytes_written = os.write(self.stdin.fileno(), chunk)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 53: ordinal not in range(128)
ERROR: share command failed
Aborting
redaktion@redaktionsrechner:~/superapp$

Seems like an encoding problem?

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

right, it seems an encoding problem, not sure what we should do in the pipe to take unicode caracter. I'll ask to mterry later on.

Changed in quickly:
status: New → Triaged
Revision history for this message
Martin Pool (mbp) wrote :

I would guess (without reading the code) that it's trying to pass your real name, containing an eszett, to gpg, and this fails. Why are you trying to run it in LANG=C? In general doing anything with non-ascii data in that locale in Python is going to be quite problematic.

You could say perhaps quickly should at least give you a clean error, but that seems like a different bug...

Revision history for this message
Kristian Kißling (kkissling) wrote :

Yes, could be a different bug. I use LANG=C according to #1. Now again without that:

redaktion@redaktionsrechner:~/superapp$ quickly --version
Quickly 0.6
  Python interpreter: /usr/bin/python 2.6.6
  Python standard library: /usr/lib/python2.6

  Quickly used library: /home/redaktion/quickly/quickly
  Quickly data path: /home/redaktion/quickly/data
  Quickly detected template directories:
          /home/redaktion/quickly/data/templates/

Copyright 2009 Rick Spencer
Copyright 2009-2010 Didier Roche
https://launchpad.net/quickly

quickly comes with ABSOLUTELY NO WARRANTY. quickly is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 3 or later.
redaktion@redaktionsrechner:~/superapp$ quickly share
Lade Launchpad-Einstellungen
Erfolgreich mit Launchpad verbunden
It seems you don't have a gpg key on your computer. Do you want to create one (this may take a while)? y/[n]: y
Traceback (most recent call last):
  File "/home/redaktion/quickly/data/templates/ubuntu-application/share.py", line 107, in <module>
    keyid = quicklyutils.get_right_gpg_key_id(launchpad)
  File "/home/redaktion/quickly/data/templates/ubuntu-application/internal/quicklyutils.py", line 354, in get_right_gpg_key_id
    launchpad.me.display_name, prefered_emails[0])]
  File "/home/redaktion/quickly/data/templates/ubuntu-application/internal/quicklyutils.py", line 298, in create_gpg_key
    result, err = gpg_instance.communicate(key_generate)
  File "/usr/lib/python2.6/subprocess.py", line 691, in communicate
    return self._communicate(input)
  File "/usr/lib/python2.6/subprocess.py", line 1222, in _communicate
    bytes_written = os.write(self.stdin.fileno(), chunk)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 53: ordinal not in range(128)
FEHLER: Befehl share fehlgeschlagen
Wird abgebrochen
redaktion@redaktionsrechner:~/superapp$

Revision history for this message
Markus Korn (thekorn) wrote :

I think the fix in quickly should be as simple as using

   result, err = gpg_instance.communicate(key_generate.encode('utf-8'))

in quicklyutils.py, line 298, (untested, just from reading the traceback)

Revision history for this message
Martin Pool (mbp) wrote :

On 5 October 2010 19:32, Markus Korn <email address hidden> wrote:
> I think the fix in quickly should be as simple as using
>
>   result, err = gpg_instance.communicate(key_generate.encode('utf-8'))
>
> in quicklyutils.py, line 298, (untested, just from reading the
> traceback)

That would probably fix it, though it's probably not the correct fix.
Strictly speaking the encoding ought to be determined by the locale
not hardcoded to utf8, but perhaps on Ubuntu it's reasonable to say it
must always be utf-8, even if the user wants something else on their
terminal? If you want to use non-ascii, you should use a unicode
locale.

--
Martin

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Right, I was pondering about forcing utf-8. I've already done that in other part of Quickly, so I assume it's same to the same here.

@Kristian: can you pull again the trunk and try it, please? (you can catch other bugs as you have non unicode caracter in your name, sorry for that and thanks for your patience).

Revision history for this message
Kristian Kißling (kkissling) wrote :

Now to something completly different:

$ bzr update lp:quickly
The authenticity of host 'bazaar.launchpad.net (91.189.90.11)' can't be established.
RSA key fingerprint is 9d:38:3a:63:b1:d5:6f:c4:44:67:53:49:2e:ee:fc:89.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bazaar.launchpad.net,91.189.90.11' (RSA) to the list of known hosts.
Permission denied (publickey).
bzr: ERROR: Connection closed: Unexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.

Same error with
$bzr branch lp:quickly

Deleted ~/.ssh and /quickly but that didn't work. Will try everything all over again with a fresh installed system, maybe that works. Any idea?

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

The fix seems to work.

I think you didn't read the messages for gpg and ssh key:

Your gpg key has been create. You have to upload it to " \
              "Launchpad. Guidance is provided in Launchpad help. " \
              "Press any key once done.

and it's the same for the ssh key. We hope to make this process automatic for natty, but this requires launchpad changes.

You'll also need to add a ppa called "ppa" to your account.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

oh sorry, I read too "Quickly" :)

ok, you can't update your branch. I think that's because Quickly created an ssh key for you. You need to upload it to your launchpad account (that's weird btw that you delete your ~/.ssh key and it still tries to use it, maybe it was still in gnome-keyring?)

after a logout/login, do you still have $ bzr branch lp:quickly trying to use the ssh key?

Revision history for this message
Kristian Kißling (kkissling) wrote :

After some painful key exchange lessons it seems to work now. The packages appeared, hooray! Thank you very much, Didier!

My new superapp 0.1 (which consists of an empty window) will probably change the world ;)

Since I'm editing an article on Quickly which is now finished: Will those changes somehow appear in 10.10 (SRU, Backports)?

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Congrats Kristian! Glad we got it :)

Yeah, those changes will be updated tomorrow for maverick. Once again, the key exchange is the painful part (well, normally, creating the keys is really really easy… We just got some bugs which are now fixed!), but uploading to launchpad and creating the ppa in an automatic way is the goal for natty (it requires some changes to launchpad, which is why it didn't get for maverick) and that will make the first run smoother.

Now that you have your environment setup. You can create your awesomeapp 0.1 and even fooapp 0.1 without a glitch! ;)

Changed in quickly:
status: Triaged → Fix Committed
Changed in quickly:
status: Fix Committed → Fix Released
Changed in quickly (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package quickly - 0.6.1-0ubuntu1

---------------
quickly (0.6.1-0ubuntu1) maverick; urgency=low

  * New bugfix release:
   + ubuntu-application-template and derivatives:
    - don't overwrite files in add command if already exists (Tony Byrne)
      (LP: #645490)
    - fix crash in in help() (Michael Terry) (LP: #649881)
    - force utf8 when creating a gpg key (LP: #640689)
   + common:
    - revert internal bzr calls to use subprocess calls again
      (LP: #648496, #642455)
    - translations update (en_GB, es, fr, uk)
    - urkkk, just saw that the tutorial contains the name and revision number.
      Update that as a workaround. Should be removed for next release.
 -- Didier Roche <email address hidden> Wed, 06 Oct 2010 12:18:39 +0200

Changed in quickly (Ubuntu):
status: Fix Committed → Fix Released
Gary Poster (gary)
Changed in launchpadlib:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.