Python keyring 模块,get_password() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用keyring.get_password()

项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = client.Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = client.Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:ozelot    作者:trycs    | 项目源码 | 文件源码
def test06(self):
        """Get password from :mod:`keyring`
        """
        password = ''.join(random.choice(string.ascii_letters) for _ in range(64))

        params = {
            'driver': 'postgresql+psycopg2',
            'host': 'my.server.com',
            'port': 5432,
            'user': 'myuser',
            'password': None,
            'database': 'mydb'
        }

        # set the password
        client.Client.store_password(params, password)

        # retrieve password directly from keyring
        pw = keyring.get_password(service_name='my.server.com:postgresql+psycopg2', username='myuser')
        self.assertEqual(pw, password)

        s = client.Client.get_connection_string(params, hide_password=False)
        self.assertEqual(s, "postgresql+psycopg2://myuser:{:s}@my.server.com:5432/mydb"
                            "".format(password))
项目:QCrash    作者:ColinDuquesnoy    | 项目源码 | 文件源码
def get_user_credentials(self):  # pragma: no cover
        # reason: hard to test methods that shows modal dialogs
        username, remember, remember_pswd = self._get_credentials_from_qsettings()

        if remember_pswd and username:
            # get password from keyring
            try:
                password = keyring.get_password('github', username)
            except RuntimeError:
                # no safe keyring backend
                _logger().warn('failed to retrieve password from keyring...')
            else:
                return username, password, remember, remember_pswd

        # ask for credentials
        username, password, remember, remember_pswd = DlgGitHubLogin.login(
            self.parent_widget, username, remember, remember_pswd)

        if remember:
            self._store_credentials(username, password, remember, remember_pswd)

        return username, password, remember, remember_pswd
项目:python-zunclient    作者:openstack    | 项目源码 | 文件源码
def auth_token(self):
        # Now is where it gets complicated since we
        # want to look into the keyring module, if it
        # exists and see if anything was provided in that
        # file that we can use.
        if not HAS_KEYRING or not self.args.os_cache:
            return None
        token = None
        try:
            block = keyring.get_password('zunclient_auth',
                                         self._make_key())
            if block:
                token, _management_url, _tenant_id = block.split('|', 2)
        except all_errors:
            pass
        return token
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = client.Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:jira_reporting_scripts    作者:andrew-hamlin-sp    | 项目源码 | 文件源码
def get_credentials(username, password):
    if not username:
        username = getpass.getuser()

    _needs_storage = True

    if not password:
        # retrieve password from system storage
        if keyring.get_keyring():
            password = keyring.get_password(KEYRING_NAME, username)
            if password:
                _needs_storage = False

    if not password:
        password = getpass.getpass('Enter password for {}: '.format(username))

    if _needs_storage and keyring.get_keyring():
        try:
            keyring.set_password(KEYRING_NAME, username, password)
        except keyring.errors.PasswordSetError as err:
            Log.error(err)

    return username, password
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:netcrawl    作者:Wyko    | 项目源码 | 文件源码
def test_get_Fernet_returns_a_key():
    fake = Faker()
    appname= '_'.join(['test_a_netcrawl_', fake.word(), fake.word()])
    username= '_'.join(['test_u_netcrawl_', fake.word(), fake.word()])

    key= manage._get_fernet_key(appname, username)

    assert isinstance(key, fernet.Fernet), 'Key [{}] is wrong type'.format(
        type(key))

    assert keyring.get_password(appname, username) is not None

    keyring.delete_password(appname, username)

    assert keyring.get_password(appname, username) is None


#===============================================================================
# def test_check_credentials_no_error():
#     config.cc.check_credentials()
#===============================================================================
项目:netcrawl    作者:Wyko    | 项目源码 | 文件源码
def _get_fernet_key(app_name= 'netcrawl',
                    username= 'netcrawl'):
    proc= 'manage._get_fernet_key'

    # Retrieve the encryption key from storage or generate one
    key= keyring.get_password(app_name, username)
    if key is None:
        log('Creating encryption key', v= logging.N, proc= proc)
        key = Fernet.generate_key()
        keyring.set_password(app_name, username, str(key, encoding='utf-8'))
    else:
        key= bytes(key, encoding='utf-8')

    # Create a Fernet key from the base key
    return Fernet(key)
    del(key)
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:zeex    作者:zbarge    | 项目源码 | 文件源码
def get_password(self, service_name, username=None, section=None, prefix=None):
        if section is None:
            section = service_name
        if prefix is not None:
            user_option = "{}_username"
        else:
            user_option = 'username'
        if username is None:
            username = self.get_safe(section, user_option, fallback=None)
        pw = keyring.get_password(service_name, username)
        if pw is None:
            if username is None:
                msg = "username was not found in settings for section '{}' & option '{}'".format(
                    section, user_option)
            else:
                msg = "password was not found for username {} and service name {}".format(
                    username, service_name)
            raise KeyError(msg)
        self.set_safe(section, user_option, username)
        return pw
项目:zeex    作者:zbarge    | 项目源码 | 文件源码
def set_password(self, service_name, username, password, **kwargs):
        keyring.set_password(service_name, username, password)
        self.get_password(service_name, username, **kwargs)
项目:aqua-monitor    作者:Deltares    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:simplewebscraper    作者:alexanderward    | 项目源码 | 文件源码
def decrypt_cookie_db(self):
        if self.platform == OperatingSystem.LINUX:
            import keyring
            from Crypto.Protocol.KDF import PBKDF2
            salt = b'saltysalt'
            length = 16
            # If running Chrome on OSX
            if sys.platform == 'darwin':
                my_pass = keyring.get_password('Chrome Safe Storage', 'Chrome')
                my_pass = my_pass.encode('utf8')
                iterations = 1003
                self.cookie_file = os.path.expanduser('~/Library/Application Support/Google/Chrome/Default/Cookies')

            # If running Chromium on Linux
            elif 'linux' in sys.platform:
                my_pass = 'peanuts'.encode('utf8')
                iterations = 1
                self.cookie_file = os.path.expanduser('~/.config/chromium/Default/Cookies')
            self.key = PBKDF2(my_pass, salt, length, iterations)
            return self.linux_decrypt_value

        elif self.platform == OperatingSystem.WINDOWS:
            return self.windows_decrypt_value
项目:SurfaceWaterTool    作者:Servir-Mekong    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:SurfaceWaterTool    作者:Servir-Mekong    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:Chromium_DepotTools    作者:p07r0457    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:alfredToday    作者:jeeftor    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:node-gn    作者:Shouqun    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:Webradio_v2    作者:Acer54    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = client.Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = client.Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:IoT_Parking    作者:leeshlay    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:depot_tools    作者:webrtc-uwp    | 项目源码 | 文件源码
def locked_get(self):
    """Retrieve Credential from file.

    Returns:
      oauth2client.client.Credentials
    """
    credentials = None
    content = keyring.get_password(self._service_name, self._user_name)

    if content is not None:
      try:
        credentials = Credentials.new_from_json(content)
        credentials.set_store(self)
      except ValueError:
        pass

    return credentials
项目:share-class    作者:junyiacademy    | 项目源码 | 文件源码
def locked_get(self):
        """Retrieve Credential from file.

        Returns:
            oauth2client.client.Credentials
        """
        credentials = None
        content = keyring.get_password(self._service_name, self._user_name)

        if content is not None:
            try:
                credentials = Credentials.new_from_json(content)
                credentials.set_store(self)
            except ValueError:
                pass

        return credentials
项目:fuzzinator    作者:renatahodovan    | 项目源码 | 文件源码
def send_mail(self, data):
        """
        Send e-mail with the provided data.

        :param data: Information to fill subject and content fields with.
        """
        if type(data) != dict:
            data = dict((self.param_name, data.decode('utf-8', 'ignore')))
        data = dict((name, raw.decode('utf-8', 'ignore') if type(raw) == bytes else raw) for name, raw in data.items())

        subject = self.subject.format(**data)
        content = self.content.format(**data)

        msg = MIMEText(content)
        msg['From'] = self.from_address
        msg['To'] = self.to_address
        msg['Subject'] = subject

        server = smtplib.SMTP(self.smtp_host, self.smtp_port)
        server.starttls()
        server.login(self.from_address, keyring.get_password('fuzzinator', self.from_address))
        server.send_message(msg)
        server.quit()
项目:python-meteosclient    作者:openstack    | 项目源码 | 文件源码
def auth_token(self):
        # Now is where it gets complicated since we
        # want to look into the keyring module, if it
        # exists and see if anything was provided in that
        # file that we can use.
        if not HAS_KEYRING or not self.args.os_cache:
            return None
        token = None
        try:
            block = keyring.get_password('meteosclient_auth',
                                         self._make_key())
            if block:
                token, _management_url, _tenant_id = block.split('|', 2)
        except all_errors:
            pass
        return token
项目:mssqlcli    作者:rtrox    | 项目源码 | 文件源码
def check_keyring(self, string):
        """
        Determine if value is in keyring, and if so, return it.

        Checks if the pattern matches the expected keyring reference style
        USE_KEYRING("name of keyring item"). If so, retrieves the proper
        value from the keyring and returns. otherwise, returns the string
        unmolested.

        keyring_app_name in the config file is used to determine the
        application name to be used for keyring lookup. This allows
        for certain convenience items, like sharing an LDAP password
        with other applications.

        :param string string: string to be checked.
        :rtype: string
        """
        app_name = self.object.get("keyring_app_name", "mssqlcli")
        match = self.matcher.match(string)
        if match is not None:
            return keyring.get_password(app_name, match.group(1))
        return string
项目:browsercookie-windows-support    作者:DavidMetcalfe    | 项目源码 | 文件源码
def get_cookies(self):
        salt = b'saltysalt'
        length = 16
        if sys.platform == 'darwin':
            # running Chrome on OSX
            my_pass = keyring.get_password('Chrome Safe Storage', 'Chrome')
            my_pass = my_pass.encode('utf8')
            iterations = 1003
            key = PBKDF2(my_pass, salt, length, iterations)

        elif sys.platform.startswith('linux'):
            # running Chrome on Linux
            my_pass = 'peanuts'.encode('utf8')
            iterations = 1
            key = PBKDF2(my_pass, salt, length, iterations)

        elif sys.platform == 'win32':
            key = None
        else:
            raise BrowserCookieError('Unsupported operating system: ' + sys.platform)

        for cookie_file in self.cookie_files:
            with create_local_copy(cookie_file) as tmp_cookie_file:
                con = sqlite3.connect(tmp_cookie_file)
                cur = con.cursor()
                cur.execute('SELECT host_key, path, secure, expires_utc, name, value, encrypted_value FROM cookies;')
                for item in cur.fetchall():
                    host, path, secure, expires, name = item[:5]
                    value = self._decrypt(item[5], item[6], key=key)
                    yield create_cookie(host, path, secure, expires, name, value)
                con.close()
项目:cbas    作者:ImmobilienScout24    | 项目源码 | 文件源码
def keyring_get_password(username):
    keyring_impl = keyring.get_keyring()
    verbose("Note: will use the backend: '{0}'".format(keyring_impl))
    password = keyring.get_password('cbas', username)
    if not password:
        info("No password found in keychain, please enter it now to store it.")
        password = prompt_get_password(username)
        keyring.set_password('cbas', username, password)
    return password
项目:cbas    作者:ImmobilienScout24    | 项目源码 | 文件源码
def get_password(password_provider, username):
    verbose("Password provider is: '{}'".format(password_provider))
    if password_provider == PROMPT:
        password = prompt_get_password(username)
    elif password_provider == KEYRING:
        password = keyring_get_password(username)
    elif password_provider == TESTING:
        password = 'PASSWORD'
    else:
        raise CMDLineExit("'{0}' is not a valid password provider.\n".
                          format(password_provider) +
                          "Valid options are: {0}".
                          format(PASSWORD_PROVIDERS))

    return password
项目:user-sync.py    作者:adobe-apiplatform    | 项目源码 | 文件源码
def get_credential(self, name, user_name, none_allowed=False):
        """
        Get the credential with the given name.  Raises an AssertionException if there
        is no credential, or if the credential is specified both in plaintext and the keyring.
        If the credential is kept in the keyring, the value of the keyring_name setting
        gives the secure storage key, and we fetch that key for the given user.
        :param name: setting name for the plaintext credential
        :param user_name: the user for whom we should fetch the service name password in secure storage
        :param none_allowed: whether the credential can be missing or empty
        :return: credential string
        """
        keyring_name = self.keyring_prefix + name + self.keyring_suffix
        scope = self.get_full_scope()
        # sometimes the credential is in plain text
        cleartext_value = self.get_string(name, True)
        # sometimes the value is in the keyring
        secure_value_key = self.get_string(keyring_name, True)
        # but it has to be in exactly one of those two places!
        if not cleartext_value and not secure_value_key and not none_allowed:
            raise AssertionException('%s: must contain setting for "%s" or "%s"' % (scope, name, keyring_name))
        if cleartext_value and secure_value_key:
            raise AssertionException('%s: cannot contain setting for both "%s" and "%s"' % (scope, name, keyring_name))
        if secure_value_key:
            try:
                import keyring
                value = keyring.get_password(service_name=secure_value_key, username=user_name)
            except Exception as e:
                raise AssertionException('%s: Error accessing secure storage: %s' % (scope, e))
        else:
            value = cleartext_value
        if not value and not none_allowed:
            raise AssertionException(
                '%s: No value in secure storage for user "%s", key "%s"' % (scope, user_name, secure_value_key))
        return value
项目:glog-cli    作者:globocom    | 项目源码 | 文件源码
def get_password_from_keyring(host, username):
    return keyring.get_password('glog_' + host, username)
项目:scarlett_os    作者:bossjones    | 项目源码 | 文件源码
def _secret_yaml(loader: SafeLineLoader,
                 node: yaml.nodes.Node):
    """Load secrets and embed it into the configuration YAML."""
    secret_path = os.path.dirname(loader.name)
    while True:
        secrets = _load_secret_yaml(secret_path)

        if node.value in secrets:
            logger.debug('Secret %s retrieved from secrets.yaml in '
                          'folder %s', node.value, secret_path)
            return secrets[node.value]

        if secret_path == os.path.dirname(sys.path[0]):
            break  # sys.path[0] set to config/deps folder by bootstrap

        secret_path = os.path.dirname(secret_path)
        if not os.path.exists(secret_path) or len(secret_path) < 5:
            break  # Somehow we got past the .scarlett_os config folder

    if keyring:
        # do some keyring stuff
        pwd = keyring.get_password(_SECRET_NAMESPACE, node.value)
        if pwd:
            logger.debug('Secret %s retrieved from keyring.', node.value)
            return pwd

    logger.error('Secret %s not defined.', node.value)
    raise ScarlettError(node.value)
项目:picam_cctv    作者:gigafide    | 项目源码 | 文件源码
def gmail(png_file):
    #add your gmail address and get your stored gmail password from keyring
    gmail_acct = "your_gmail address"
    #if you are not using keyring, comment out the text below
    app_spec_pwd = keyring.get_password("credentials", "gmail")
    #if you are not using keyring, uncomment the text below
    #app_spec_pwd = "your_gmail_password"

    #create variables for the "to" and "from" email addresses
    TO = ["email_address_of_receiver"]
    FROM = "email_address_of_sender"

    #asemble the message as "MIMEMultipart" mixed
    msg = MIMEMultipart('mixed')
    msg['Subject'] = 'Intruder Alert!'
    msg['From'] = FROM
    msg['To'] = ', '.join(TO)
    body = MIMEText('Motion was detected on your security camera.', 'plain')
    msg.attach(body)

    #open up an image file and attach it to the message
    img_data = open(png_file, 'rb')
    image = MIMEImage(img_data.read())
    img_data.close()
    msg.attach(image)

    #open up the SMTP server, start a tls connection, login, send, and close
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.ehlo
    server.login(gmail_acct, app_spec_pwd)
    server.sendmail(FROM, TO, msg.as_string())
    server.close()
项目:github-reviewboard-sync    作者:Apptimize-OSS    | 项目源码 | 文件源码
def _get_password(system, username, refresh=False):
    system_store_name = 'sync-{0}'.format(system)
    password = None
    if not refresh:
        password = keyring.get_password(system_store_name, username)
    if password is None:
        password = getpass('{0} password for "{1}":'.format(system, username))
        keyring.set_password(system_store_name, username, password)
    return password
项目:competitive-cli    作者:GDGVIT    | 项目源码 | 文件源码
def get_account(self, index):
        index = str(index)
        website, username = self.data["accounts"][index]
        password = keyring.get_password(website, username)
        return website, username, password
项目:modman    作者:haihala    | 项目源码 | 文件源码
def get_credentials():
        pair = keyring.get_password(APP_NAME, getuser())
        if pair is None:
            return None
        assert "\n" in pair
        return Credentials(*pair.split("\n", 1))
项目:ozelot    作者:trycs    | 项目源码 | 文件源码
def _get_password(params):
        """Get the password for a database connection from :mod:`keyring`

        Args:
            params (dict): database configuration, as defined in :mod:`ozelot.config`

        Returns:
            str: password
        """
        user_name = params['user']
        service_name = params['host'] + ':' + params['driver']
        return keyring.get_password(service_name=service_name,
                                    username=user_name)
项目:imapautofiler    作者:dhellmann    | 项目源码 | 文件源码
def get_password(self):
        return self.password
项目:imapautofiler    作者:dhellmann    | 项目源码 | 文件源码
def get_password(self):
        password = keyring.get_password(self.hostname, self.username)
        if not password:
            LOG.debug("No keyring password; getting one interactively")
            password = getpass.getpass(
                'Password for {} (will be stored in the system keyring):'
                .format(self.username)
            )
            keyring.set_password(self.hostname, self.username, password)

        return keyring.get_password(self.hostname, self.username)
项目:imapautofiler    作者:dhellmann    | 项目源码 | 文件源码
def get_password(self):
        return getpass.getpass('Password for {}:'.format(self.username))