/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-10-23 17:59:52 UTC
  • mfrom: (3788.1.5 msvc_python24)
  • Revision ID: pqm@pqm.ubuntu.com-20081023175952-0gr8np56nf6ab5yn
(jam) Allow extensions to compile for python2.4 and using msvc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2007 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Functions to manage the user's Launchpad user ID.
18
18
 
33
33
 
34
34
 
35
35
class NoRegisteredSSHKeys(errors.BzrError):
36
 
    _fmt = "The user %(user)s has not registered any SSH keys with Launchpad.\n" \
37
 
        "See <https://launchpad.net/people/+me>"
 
36
    _fmt = "The user %(user)s has not registered any SSH keys with Launchpad."
38
37
 
39
38
 
40
39
class MismatchedUsernames(errors.BzrError):
55
54
    username = _config.get_user_option('launchpad_username')
56
55
    if username is not None:
57
56
        auth = AuthenticationConfig()
58
 
        auth_username = _get_auth_user(auth)
 
57
        auth_usernames = _get_auth_user(auth)
 
58
        for auth_username in auth_usernames.values():
 
59
            if auth_username is not None and auth_username != username:
 
60
                raise MismatchedUsernames()
59
61
        # Auto-upgrading
60
 
        if auth_username is None:
 
62
        if None in auth_usernames.values():
61
63
            trace.note('Setting ssh/sftp usernames for launchpad.net.')
62
64
            _set_auth_user(username, auth)
63
 
        elif auth_username != username:
64
 
            raise MismatchedUsernames()
65
65
    return username
66
66
 
67
67
 
80
80
def _get_auth_user(auth=None):
81
81
    if auth is None:
82
82
        auth = AuthenticationConfig()
83
 
    username = auth.get_user('ssh', '.launchpad.net')
84
 
    return username
 
83
    return {'production': auth.get_user('ssh', 'bazaar.launchpad.net'),
 
84
            'staging': auth.get_user('ssh', 'bazaar.staging.launchpad.net'),}
85
85
 
86
86
def _set_auth_user(username, auth=None):
87
87
    if auth is None:
88
88
        auth = AuthenticationConfig()
89
89
    auth.set_credentials(
90
 
        'Launchpad', '.launchpad.net', username, 'ssh')
 
90
        'Launchpad', 'bazaar.launchpad.net', username, 'ssh')
 
91
    auth.set_credentials(
 
92
        'Launchpad Staging', 'bazaar.staging.launchpad.net', username, 'ssh')
91
93
 
92
94
 
93
95
def check_lp_login(username, _transport=None):