~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-13 06:08:53 UTC
  • mfrom: (4737.1.1 merge-2.0-into-devel)
  • Revision ID: pqm@pqm.ubuntu.com-20091013060853-erk2aaj80fnkrv25
(andrew) Merge lp:bzr/2.0 into lp:bzr, including fixes for #322807,
        #389413, #402623 and documentation improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
than once for each place that needs to take it into account.
21
21
"""
22
22
 
23
 
from __future__ import absolute_import
 
23
from bzrlib import errors, trace
 
24
from bzrlib.config import AuthenticationConfig, GlobalConfig
 
25
from bzrlib.transport import get_transport
24
26
 
25
 
from bzrlib import (
26
 
    errors,
27
 
    trace,
28
 
    transport,
29
 
    )
30
 
from bzrlib.config import AuthenticationConfig, GlobalStack
31
 
from bzrlib.i18n import gettext
32
27
 
33
28
LAUNCHPAD_BASE = 'https://launchpad.net/'
34
29
 
55
50
        disagree about username.
56
51
    """
57
52
    if _config is None:
58
 
        _config = GlobalStack()
 
53
        _config = GlobalConfig()
59
54
 
60
 
    username = _config.get('launchpad_username')
 
55
    username = _config.get_user_option('launchpad_username')
61
56
    if username is not None:
62
57
        auth = AuthenticationConfig()
63
58
        auth_username = _get_auth_user(auth)
64
59
        # Auto-upgrading
65
60
        if auth_username is None:
66
 
            trace.note(gettext('Setting ssh/sftp usernames for launchpad.net.'))
 
61
            trace.note('Setting ssh/sftp usernames for launchpad.net.')
67
62
            _set_auth_user(username, auth)
68
63
        elif auth_username != username:
69
64
            raise MismatchedUsernames()
72
67
 
73
68
def _set_global_option(username, _config=None):
74
69
    if _config is None:
75
 
        _config = GlobalStack()
76
 
    _config.set('launchpad_username', username)
 
70
        _config = GlobalConfig()
 
71
    _config.set_user_option('launchpad_username', username)
77
72
 
78
73
 
79
74
def set_lp_login(username, _config=None):
102
97
    uploaded SSH keys.
103
98
    """
104
99
    if _transport is None:
105
 
        _transport = transport.get_transport_from_url(LAUNCHPAD_BASE)
 
100
        _transport = get_transport(LAUNCHPAD_BASE)
106
101
 
107
102
    try:
108
103
        data = _transport.get_bytes('~%s/+sshkeys' % username)