当前位置: 首页>>代码示例>>Python>>正文


Python keyring.get_password方法代码示例

本文整理汇总了Python中keyring.get_password方法的典型用法代码示例。如果您正苦于以下问题:Python keyring.get_password方法的具体用法?Python keyring.get_password怎么用?Python keyring.get_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keyring的用法示例。


在下文中一共展示了keyring.get_password方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_temporary_credential

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def read_temporary_credential(self, host, account, user, session_parameters):
        if session_parameters.get(PARAMETER_CLIENT_STORE_TEMPORARY_CREDENTIAL, False):
            id_token = None
            if IS_MACOS or IS_WINDOWS:
                if not keyring:
                    # we will leave the exception for write_temporary_credential function to raise
                    return
                new_target = convert_target(host, user)
                try:
                    id_token = keyring.get_password(new_target, user.upper())
                except keyring.errors.KeyringError as ke:
                    logger.debug("Could not retrieve id_token from secure storage : {}".format(str(ke)))
            elif IS_LINUX:
                read_temporary_credential_file()
                id_token = TEMPORARY_CREDENTIAL.get(
                    account.upper(), {}).get(user.upper())
            else:
                logger.debug("connection parameter enable_sso_temporary_credential not set or OS not support")
            self._rest.id_token = id_token
        return 
开发者ID:snowflakedb,项目名称:snowflake-connector-python,代码行数:22,代码来源:auth.py

示例2: locked_get

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
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 
开发者ID:mortcanty,项目名称:earthengine,代码行数:19,代码来源:keyring_storage.py

示例3: get_http_auth

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get_http_auth(self, name):
        auth = self._config.get("http-basic.{}".format(name))
        if not auth:
            username = self._config.get("http-basic.{}.username".format(name))
            password = self._config.get("http-basic.{}.password".format(name))
            if not username and not password:
                return None
        else:
            username, password = auth["username"], auth.get("password")
            if password is None:
                password = self.keyring.get_password(name, username)

        return {
            "username": username,
            "password": password,
        } 
开发者ID:python-poetry,项目名称:poetry,代码行数:18,代码来源:password_manager.py

示例4: locked_get

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
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 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:19,代码来源:keyring_storage.py

示例5: get_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get_password(self, key):
        try:
            import keyring
        except ImportError:
            return None
        token = None
        try:
            token = keyring.get_password(key, self._USERNAME)
        except Exception as ex:  # pylint: disable=broad-except
            # fetch credentials from file if keyring is missing or malfunctioning
            if sys.platform.startswith(self._LINUX_PLATFORM):
                token = None
            else:
                raise CLIError(ex)
        # look for credential in file too for linux if token is None
        if token is None and sys.platform.startswith(self._LINUX_PLATFORM):
            token = self.get_PAT_from_file(key)
        return token 
开发者ID:Azure,项目名称:azure-devops-cli-extension,代码行数:20,代码来源:credential_store.py

示例6: _parse_parameters

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def _parse_parameters(names, options):
    """Parse parameters, with a tuple of names for keyring context"""
    for key in options.keys():
        val = options[key]
        if isinstance(val, dict):
            val = _parse_parameters(names + (key,), val)
        if isinstance(val, string_types) and len(val) > 1 and val[0] == "^":
            # Decode a secret from the keystore
            val = val[1:]
            service = ".".join(names) or "_"
            if service == "resilient":
                # Special case, becuase of the way we parse commandlines, treat this as root
                service = "_"
            logger.debug("keyring get('%s', '%s')", service, val)
            val = keyring.get_password(service, val)
        if isinstance(val, string_types) and len(val) > 1 and val[0] == "$":
            # Read a value from the environment
            val = val[1:]
            logger.debug("env('%s')", val)
            val = os.environ.get(val)
        options[key] = val
    return options 
开发者ID:ibmresilient,项目名称:resilient-python-api,代码行数:24,代码来源:co3argparse.py

示例7: get_keychain_key

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get_keychain_key(self):
        key_from_env = os.environ.get("CUMULUSCI_KEY")
        try:
            key_from_keyring = keyring.get_password("cumulusci", "CUMULUSCI_KEY")
            has_functioning_keychain = True
        except Exception as e:
            keychain_exception = e
            key_from_keyring = None
            has_functioning_keychain = False
        # If no key in environment or file, generate one
        key = key_from_env or key_from_keyring
        if key is None:
            if has_functioning_keychain:
                key = random_alphanumeric_underscore(length=16)
            else:
                raise KeychainKeyNotFound(
                    "Unable to store CumulusCI encryption key. "
                    "You can configure it manually by setting the CUMULUSCI_KEY "
                    "environment variable to a random 16-character string. "
                    f"ERROR: {keychain_exception}"
                )
        if has_functioning_keychain and not key_from_keyring:
            keyring.set_password("cumulusci", "CUMULUSCI_KEY", key)
        return key 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:26,代码来源:runtime.py

示例8: locked_get

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
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 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:19,代码来源:keyring_storage.py

示例9: update_connections

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def update_connections(self):
        if not os.path.exists(CONNECTIONS_FILE):
            return
        with open(CONNECTIONS_FILE) as f:
            data = json.load(f)
        for key in data:
            if key in self._connections:
                self._connections[key].update_config(data[key])
            else:
                config = data[key].copy()
                password = keyring.get_password('runsqlrun', key)
                if password is not None:
                    config['password'] = password
                conn = Connection(key, config)
                self._connections[key] = conn
                conn.start()
        # remove deleted connections
        for key in list(self._connections):
            if key not in data:
                conn = self._connections.pop(key)
                conn.keep_running = False
                conn.join()
                self.emit('connection-deleted', conn.key) 
开发者ID:andialbrecht,项目名称:runsqlrun,代码行数:25,代码来源:manager.py

示例10: get

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get(self, namespace, path, default=None, from_keyring=False):
        path = '%s.%s' % (namespace, path)
        if from_keyring:
            value = keyring.get_password(APPNAME, path)
        else:
            value = utils.rget(self.values, path)
        return value if value is not None else default 
开发者ID:pkkid,项目名称:pkmeter,代码行数:9,代码来源:pkconfig.py

示例11: get_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get_password(self, account):
        try:
            import keyring
            return keyring.get_password(self.identifier, account)
        except ImportError:
            return None 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:8,代码来源:config.py

示例12: get_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get_password(self, name, username):
        if not self.is_available():
            return

        import keyring
        import keyring.errors

        name = self.get_entry_name(name)

        try:
            return keyring.get_password(name, username)
        except (RuntimeError, keyring.errors.KeyringError):
            raise KeyRingError(
                "Unable to retrieve the password for {} from the key ring".format(name)
            ) 
开发者ID:python-poetry,项目名称:poetry,代码行数:17,代码来源:password_manager.py

示例13: get_pypi_token

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def get_pypi_token(self, name):
        if not self.keyring.is_available():
            return self._config.get("pypi-token.{}".format(name))

        return self.keyring.get_password(name, "__token__") 
开发者ID:python-poetry,项目名称:poetry,代码行数:7,代码来源:password_manager.py

示例14: handle_basic_auth

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import get_password [as 别名]
def handle_basic_auth(auth, server):
    if auth.get("password"):
        password = auth["password"]
        if input("Would you like to remember password in OS keyring? (y/n)") == "y":
            keyring.set_password(server, auth["username"], password)
    else:
        print("Getting password from keyring...")
        password = keyring.get_password(server, auth["username"])
        assert password, "No password provided!"
    return (auth["username"], password) 
开发者ID:pycontribs,项目名称:jira,代码行数:12,代码来源:jirashell.py


注:本文中的keyring.get_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。