コード例 #1
0
def get_lp_login(_config=None):
    """Return the user's Launchpad username.

    :raises: MismatchedUsername if authentication.conf and bazaar.conf
        disagree about username.
    """
    if _config is None:
        _config = GlobalStack()

    username = _config.get('launchpad_username')
    if username is not None:
        auth = AuthenticationConfig()
        auth_username = _get_auth_user(auth)
        # Auto-upgrading
        if auth_username is None:
            trace.note(gettext('Setting ssh/sftp usernames for launchpad.net.'))
            _set_auth_user(username, auth)
        elif auth_username != username:
            raise MismatchedUsernames()
    return username
コード例 #2
0
def _set_auth_user(username, auth=None):
    if auth is None:
        auth = AuthenticationConfig()
    auth.set_credentials(
        'Launchpad', '.launchpad.net', username, 'ssh')
コード例 #3
0
def _get_auth_user(auth=None):
    if auth is None:
        auth = AuthenticationConfig()
    username = auth.get_user('ssh', '.launchpad.net')
    return username