本文整理汇总了Python中gi.repository.Secret.password_store_sync方法的典型用法代码示例。如果您正苦于以下问题:Python Secret.password_store_sync方法的具体用法?Python Secret.password_store_sync怎么用?Python Secret.password_store_sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Secret
的用法示例。
在下文中一共展示了Secret.password_store_sync方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_lastfm_settings
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def _update_lastfm_settings(self, sync=False):
"""
Update lastfm settings
@param sync as bool
"""
try:
if Lp().lastfm is not None and Secret is not None:
schema = Secret.Schema.new("org.gnome.Lollypop",
Secret.SchemaFlags.NONE,
SecretSchema)
Secret.password_store_sync(schema, SecretAttributes,
Secret.COLLECTION_DEFAULT,
"org.gnome.Lollypop"
".lastfm.login %s" %
self.__login.get_text(),
self.__password.get_text(),
None)
Lp().settings.set_value('lastfm-login',
GLib.Variant('s',
self.__login.get_text()))
if sync:
Lp().lastfm.connect_sync(self.__password.get_text())
else:
Lp().lastfm.connect(self.__password.get_text())
except Exception as e:
print("Settings::_update_lastfm_settings(): %s" % e)
示例2: insert
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def insert(secret_id, provider, username, token):
"""
Save a secret OTP token.
:param secret_id: The secret ID associated to the OTP token
:param provider: the provider name
:param username: the username
:param token: the secret OTP token.
"""
schema = Keyring.get_default().schema
data = {
"id": str(secret_id),
"name": str(username),
}
Secret.password_store_sync(
schema,
data,
Secret.COLLECTION_DEFAULT,
"{provider} OTP ({username})".format(
provider=provider, username=username),
token,
None
)
示例3: set_account_password
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def set_account_password(email, password):
attrs = {"email": email}
if password:
Secret.password_store_sync(_ACCOUNT_SCHEMA, attrs, Secret.COLLECTION_DEFAULT,
"Pandora Account", password, None)
else:
Secret.password_clear_sync(_ACCOUNT_SCHEMA, attrs, None)
示例4: store_password
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def store_password(self, scheme, host, username, password):
"""Return the password of [email protected]"""
template = dict(zip(self.category, (scheme, host, username)))
self.clear_password(scheme, host, username)
try:
Secret.password_store_sync(
self.schema, template, Secret.COLLECTION_DEFAULT, host,
password, None)
except Secret.SECRET_ERROR_PROTOCOL:
pass
示例5: testValueGet
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def testValueGet(self):
Secret.password_store_sync(EXAMPLE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
'the label', 'the password', None)
service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE, None)
items = service.search_sync(EXAMPLE_SCHEMA, { 'even': 'true' },
SecretUnstable.SearchFlags.ALL | SecretUnstable.SearchFlags.LOAD_SECRETS,
None)
item = items[0]
item_secret = item.get_secret()
self.assertEqual(item_secret.get(), "the password")
示例6: setTokens
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def setTokens(self, user, access_token, refresh_token):
attributes = {
"user": user,
"scope": self.scope,
}
Secret.password_store_sync(self.TOKEN_SCHEMA, attributes,
Secret.COLLECTION_DEFAULT,
"Mail access to %s for %s" % (self.scope, user),
self.encodeTokens(access_token, refresh_token),
None
)
示例7: store
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def store():
attributes = get_attributes()
if 'password' in attributes:
password = attributes['password']
del attributes['password']
else:
sys.exit(1)
Secret.password_store_sync(
GIT_CREDENTIALS_SCHEMA,
attributes,
Secret.COLLECTION_DEFAULT,
"%s://%[email protected]%s" %(attributes['protocol'], attributes['username'], attributes['host'] ),
password,
None
)
示例8: set_account_password
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def set_account_password(email, password, previous_email=None):
if previous_email and previous_email != email:
if not _clear_account_password(previous_email):
logging.warning('Failed to clear previous account')
if not password:
return _clear_account_password(email)
attrs = {"email": email}
if password == get_account_password(email):
logging.debug('Password unchanged')
return False
Secret.password_store_sync(_ACCOUNT_SCHEMA, attrs, Secret.COLLECTION_DEFAULT,
"Pandora Account", password, None)
return True
示例9: _update_lastfm_settings
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def _update_lastfm_settings(self, sync=False):
if Lp.lastfm is not None and Secret is not None:
schema = Secret.Schema.new("org.gnome.Lollypop",
Secret.SchemaFlags.NONE,
SecretSchema)
Secret.password_store_sync(schema, SecretAttributes,
Secret.COLLECTION_DEFAULT,
"org.gnome.Lollypop.lastfm.login %s" %
self._login.get_text(),
self._password.get_text(),
None)
Lp.settings.set_value('lastfm-login',
GLib.Variant('s', self._login.get_text()))
if sync:
Lp.lastfm.connect_sync(self._password.get_text())
else:
Lp.lastfm.connect(self._password.get_text())
示例10: testSynchronous
# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store_sync [as 别名]
def testSynchronous(self):
attributes = { "number": "9", "string": "nine", "even": "false" }
password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
self.assertEqual(None, password)
stored = Secret.password_store_sync(STORE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
"The number nine", "999", None)
self.assertEqual(True, stored);
password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
self.assertEqual("999", password)