~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/account.py

  • Committer: Andrew Starr-Bochicchio
  • Date: 2015-07-31 01:04:41 UTC
  • mto: This revision was merged to the branch mainline in revision 6606.
  • Revision ID: a.starr.b@gmail.com-20150731010441-3domwjjtnjijxlr2
Use hexlify() from binascii directly as paramiko removed hexify().

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
than once for each place that needs to take it into account.
21
21
"""
22
22
 
 
23
from __future__ import absolute_import
 
24
 
23
25
from bzrlib import (
24
26
    errors,
25
27
    trace,
26
28
    transport,
27
29
    )
28
 
from bzrlib.config import AuthenticationConfig, GlobalConfig
29
 
 
 
30
from bzrlib.config import AuthenticationConfig, GlobalStack
 
31
from bzrlib.i18n import gettext
30
32
 
31
33
LAUNCHPAD_BASE = 'https://launchpad.net/'
32
34
 
53
55
        disagree about username.
54
56
    """
55
57
    if _config is None:
56
 
        _config = GlobalConfig()
 
58
        _config = GlobalStack()
57
59
 
58
 
    username = _config.get_user_option('launchpad_username')
 
60
    username = _config.get('launchpad_username')
59
61
    if username is not None:
60
62
        auth = AuthenticationConfig()
61
63
        auth_username = _get_auth_user(auth)
62
64
        # Auto-upgrading
63
65
        if auth_username is None:
64
 
            trace.note('Setting ssh/sftp usernames for launchpad.net.')
 
66
            trace.note(gettext('Setting ssh/sftp usernames for launchpad.net.'))
65
67
            _set_auth_user(username, auth)
66
68
        elif auth_username != username:
67
69
            raise MismatchedUsernames()
70
72
 
71
73
def _set_global_option(username, _config=None):
72
74
    if _config is None:
73
 
        _config = GlobalConfig()
74
 
    _config.set_user_option('launchpad_username', username)
 
75
        _config = GlobalStack()
 
76
    _config.set('launchpad_username', username)
75
77
 
76
78
 
77
79
def set_lp_login(username, _config=None):
100
102
    uploaded SSH keys.
101
103
    """
102
104
    if _transport is None:
103
 
        _transport = transport.get_transport(LAUNCHPAD_BASE)
 
105
        _transport = transport.get_transport_from_url(LAUNCHPAD_BASE)
104
106
 
105
107
    try:
106
108
        data = _transport.get_bytes('~%s/+sshkeys' % username)