python类set_password()的实例源码

gutil.py 文件源码 项目:bcloud 作者: wangYanJava 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def dump_profile(profile):
    '''?????????.

    ???????????????, ??????????, ???keyring??
    ???.
    ???????, ???????.
    '''
    profile = profile.copy()
    path = os.path.join(Config.CONF_DIR, profile['username'])
    if profile['remember-password'] and profile['password']:
        for i in range(RETRIES):
            try:
                keyring.set_password(Config.DBUS_APP_NAME, profile['username'],
                                     profile['password'])
                break
            except dbus.exceptions.DBusException:
                logger.error(traceback.format_exc())
    profile['password'] = ''
    with open(path, 'w') as fh:
        json.dump(profile, fh)
credential_store.py 文件源码 项目:jira_reporting_scripts 作者: andrew-hamlin-sp 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
manage.py 文件源码 项目:netcrawl 作者: Wyko 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
collection.py 文件源码 项目:zeex 作者: zbarge 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_password(self, service_name, username, password, **kwargs):
        keyring.set_password(service_name, username, password)
        self.get_password(service_name, username, **kwargs)
login.py 文件源码 项目:config-sesame 作者: 1and1 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def login(ctx):
    """Set or change Vault login credentials in your keyring."""
    if not keyring:
        raise UsageError("'keyring' support is not available, please read"
            " 'https://config-sesame.readthedocs.io/en/latest/deploy.html'!", ctx=ctx)
    url, user, token, _ = vault.default_credentials()
    if not url:
        raise UsageError("You MUST provide a VAULT_ADDR!", ctx=ctx)
    if token:
        click.secho("WARN: You have a VAULT_TOKEN variable in your environment,"
                    " which will override any keyring credentials!",
                    fg='yellow', bg='black', bold=True, reverse=True)

    click.echo("Please enter credentials for storing in {}.{}..."
               .format(keyring.get_keyring().__class__.__module__, keyring.get_keyring().__class__.__name__))
    access = security.Credentials(url)
    user, token = access.auth_pair(force_console=True)  # Prompt for new password
    keyring.set_password(url, user, token)
    click.echo("Updated {}'s password (token) for {}".format(user, url))
password_providers.py 文件源码 项目:cbas 作者: ImmobilienScout24 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
keyring_storage.py 文件源码 项目:oscars2016 作者: 0x0ece 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
        """Write Credentials to file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name,
                             credentials.to_json())
keyring_storage.py 文件源码 项目:oscars2016 作者: 0x0ece 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def locked_delete(self):
        """Delete Credentials file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name, '')
keyring_storage.py 文件源码 项目:sndlatr 作者: Schibum 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
    """Write Credentials to file.

    Args:
      credentials: Credentials, the credentials to store.
    """
    keyring.set_password(self._service_name, self._user_name,
                         credentials.to_json())
keyring_storage.py 文件源码 项目:sndlatr 作者: Schibum 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def locked_delete(self):
    """Delete Credentials file.

    Args:
      credentials: Credentials, the credentials to store.
    """
    keyring.set_password(self._service_name, self._user_name, '')
utils.py 文件源码 项目:glog-cli 作者: globocom 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def store_password_in_keyring(host, username, password):
    keyring.set_password('glog_' + host, username, password)
keyring_storage.py 文件源码 项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
        """Write Credentials to file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name,
                             credentials.to_json())
keyring_storage.py 文件源码 项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def locked_delete(self):
        """Delete Credentials file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name, '')
keyring_storage.py 文件源码 项目:office-interoperability-tools 作者: milossramek 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
    """Write Credentials to file.

    Args:
      credentials: Credentials, the credentials to store.
    """
    keyring.set_password(self._service_name, self._user_name,
                         credentials.to_json())
keyring_storage.py 文件源码 项目:office-interoperability-tools 作者: milossramek 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def locked_delete(self):
    """Delete Credentials file.

    Args:
      credentials: Credentials, the credentials to store.
    """
    keyring.set_password(self._service_name, self._user_name, '')
credentials.py 文件源码 项目:github-reviewboard-sync 作者: Apptimize-OSS 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
CLI_helper.py 文件源码 项目:competitive-cli 作者: GDGVIT 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def insert(self, website, username, password):
        if [website, username] in self.data["accounts"].values():
            return

        new_index = self.number_of_accounts + 1

        self.account = new_index
        self.number_of_accounts += 1
        self.data["accounts"][new_index] = [website, username]
        keyring.set_password(website, username, password)
CLI_helper.py 文件源码 项目:competitive-cli 作者: GDGVIT 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def update(self, key, password):
        key = str(key)
        if key not in self.data["accounts"]:
            print("Account with given index does not exist")
            return
        website, username = self.data["accounts"][key]
        keyring.delete_password(website, username)
        keyring.set_password(website, username, password)
        return
keyring_storage.py 文件源码 项目:deb-python-oauth2client 作者: openstack 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
        """Write Credentials to file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name,
                             credentials.to_json())
keyring_storage.py 文件源码 项目:deb-python-oauth2client 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def locked_delete(self):
        """Delete Credentials file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name, '')
credentials.py 文件源码 项目:modman 作者: haihala 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def set_credentials(cred):
        assert isinstance(cred, Credentials)
        return keyring.set_password(APP_NAME, getuser(), "\n".join([cred.username, cred.password]))
client.py 文件源码 项目:ozelot 作者: trycs 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def store_password(params, password):
        """Store the password for a database connection using :mod:`keyring`

        Use the ``user`` field as the user name and ``<host>:<driver>`` as service name.

        Args:
            params (dict): database configuration, as defined in :mod:`ozelot.config`
            password (str): password to store
        """
        user_name = params['user']
        service_name = params['host'] + ':' + params['driver']
        keyring.set_password(service_name=service_name,
                             username=user_name,
                             password=password)
secrets.py 文件源码 项目:imapautofiler 作者: dhellmann 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
github.py 文件源码 项目:QCrash 作者: ColinDuquesnoy 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _store_credentials(self, username, password, remember, remember_pswd):
        if remember:
            self.qsettings().setValue('github/username', username)
        if remember_pswd:
            try:
                keyring.set_password('github', username, password)
            except RuntimeError:  # pragma: no cover
                _logger().warn('failed to save password in keyring, you '
                               'will be prompted for your credentials '
                               'next time you want to report an issue')
                remember_pswd = False
        self.qsettings().setValue(
            'github/remember_credentials', int(remember))
        self.qsettings().setValue(
            'github/remember_password', int(remember_pswd))
widgets.py 文件源码 项目:mcg 作者: coderkun 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def on_connection_panel_connection_changed(self, widget, host, port, password, image_dir):
        self._settings.set_string(Window.SETTING_HOST, host)
        self._settings.set_int(Window.SETTING_PORT, port)
        if use_keyring:
            if password:
                keyring.set_password(ZeroconfProvider.KEYRING_SYSTEM, ZeroconfProvider.KEYRING_USERNAME, password)
            else:
                if keyring.get_password(ZeroconfProvider.KEYRING_SYSTEM, ZeroconfProvider.KEYRING_USERNAME):
                   keyring.delete_password(ZeroconfProvider.KEYRING_SYSTEM, ZeroconfProvider.KEYRING_USERNAME)
        self._settings.set_string(Window.SETTING_IMAGE_DIR, image_dir)
widgets.py 文件源码 项目:mcg 作者: coderkun 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def set_password(self, password):
        if password is None:
            password = ""
        self._password_entry.set_text(password)
shell.py 文件源码 项目:python-zunclient 作者: openstack 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def save(self, auth_token, management_url, tenant_id):
        if not HAS_KEYRING or not self.args.os_cache:
            return
        if (auth_token == self.auth_token and
                management_url == self.management_url):
            # Nothing changed....
            return
        if not all([management_url, auth_token, tenant_id]):
            raise ValueError("Unable to save empty management url/auth token")
        value = "|".join([str(auth_token),
                          str(management_url),
                          str(tenant_id)])
        keyring.set_password("zunclient_auth", self._make_key(), value)
keyring_storage.py 文件源码 项目:REMAP 作者: REMAPApp 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
        """Write Credentials to file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name,
                             credentials.to_json())
keyring_storage.py 文件源码 项目:REMAP 作者: REMAPApp 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def locked_delete(self):
        """Delete Credentials file.

        Args:
            credentials: Credentials, the credentials to store.
        """
        keyring.set_password(self._service_name, self._user_name, '')
keyring_storage.py 文件源码 项目:REMAP 作者: REMAPApp 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def locked_put(self, credentials):
    """Write Credentials to file.

    Args:
      credentials: Credentials, the credentials to store.
    """
    keyring.set_password(self._service_name, self._user_name,
                         credentials.to_json())


问题


面经


文章

微信
公众号

扫码关注公众号