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
def _set_auth_user(username, auth=None): if auth is None: auth = AuthenticationConfig() auth.set_credentials( 'Launchpad', '.launchpad.net', username, 'ssh')
def _get_auth_user(auth=None): if auth is None: auth = AuthenticationConfig() username = auth.get_user('ssh', '.launchpad.net') return username