本文整理汇总了Python中gi.repository.GnomeKeyring.item_delete_sync方法的典型用法代码示例。如果您正苦于以下问题:Python GnomeKeyring.item_delete_sync方法的具体用法?Python GnomeKeyring.item_delete_sync怎么用?Python GnomeKeyring.item_delete_sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GnomeKeyring
的用法示例。
在下文中一共展示了GnomeKeyring.item_delete_sync方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_by_id
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def remove_by_id(self, uid):
"""
Remove an account by uid
:param uid: (int) account uid
:return:
"""
secret_code = self.get_secret_code(uid)
if secret_code:
found = False
(result, ids) = GK.list_item_ids_sync("TwoFactorAuth")
for gid in ids:
(result, item) = GK.item_get_info_sync("TwoFactorAuth", gid)
if result == GK.Result.OK:
if item.get_display_name().strip("'") == secret_code:
found = True
break
if found:
GK.item_delete_sync("TwoFactorAuth", gid)
query = "DELETE FROM accounts WHERE uid=?"
try:
self.conn.execute(query, (uid,))
self.conn.commit()
except Exception as e:
logging.error(
"SQL: Couldn't remove account by uid : %s with error : %s" % (uid, str(e)))
示例2: delete_credentials
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def delete_credentials(self, user):
attrs = attributes({
"user": user,
"server": self._server,
"protocol": self._protocol
})
result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.NETWORK_PASSWORD, attrs)
for item in items:
GnomeKeyring.item_delete_sync(self._keyring, item.item_id)
示例3: _migrate_keyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def _migrate_keyring(self):
attrs = GnomeKeyring.Attribute.list_new()
GnomeKeyring.Attribute.list_append_string(attrs, 'application', 'Mailnag')
result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.GENERIC_SECRET, attrs)
if result == GnomeKeyring.Result.OK:
for i in items:
result, info = GnomeKeyring.item_get_info_sync(self._defaultKeyring, i.item_id)
self.set(info.get_display_name(), i.secret)
GnomeKeyring.item_delete_sync(self._defaultKeyring, i.item_id)
示例4: remove_credentials
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def remove_credentials(self, acc):
self.lock.acquire()
try:
logger.debug("Removing credentias from gnome keyring for the account: %s" % (acc.get_name()))
if hasattr(acc, "keyringid"):
gk.item_delete_sync(self._KEYRING_NAME, int(acc.keyringid))
logger.debug("Credentials removed")
else:
logger.debug("The account has not credentials asigned, continue")
finally:
self.lock.release()
示例5: remove
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def remove(self, accounts):
# create list of all valid accounts
valid_accounts = []
for acc in accounts:
protocol = 'imap' if acc.imap else 'pop'
valid_accounts.append(self.KEYRING_ITEM_NAME % \
(protocol, acc.user, acc.server))
# find and delete invalid entries
(result, ids) = GnomeKeyring.list_item_ids_sync(self._defaultKeyring)
if result == GnomeKeyring.Result.OK:
displayNameDict = {}
for identity in ids:
(result, item) = GnomeKeyring.item_get_info_sync(self._defaultKeyring, identity)
displayNameDict[item.get_display_name()] = identity
for key in displayNameDict.keys():
if key.startswith('Mailnag password for') \
and key not in valid_accounts:
GnomeKeyring.item_delete_sync(self._defaultKeyring, displayNameDict[key])
示例6: delete_password
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def delete_password(self, service, username):
"""Delete the password for the username of the service.
"""
items = self._find_passwords(service, username, deleting=True)
if not items:
raise PasswordDeleteError("Password not found")
for current in items:
result = GnomeKeyring.item_delete_sync(current.keyring, current.item_id)
if result == GnomeKeyring.Result.CANCELLED:
raise PasswordDeleteError("Cancelled by user")
elif result != GnomeKeyring.Result.OK:
raise PasswordDeleteError(result.value_name)
示例7: delete_password
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def delete_password(self, service, username):
"""Delete the password for the username of the service.
"""
from gi.repository import GnomeKeyring
attrs = GnomeKeyring.Attribute.list_new()
GnomeKeyring.Attribute.list_append_string(attrs, 'username', username)
GnomeKeyring.Attribute.list_append_string(attrs, 'domain', service)
result, items = GnomeKeyring.find_items_sync(
GnomeKeyring.ItemType.NETWORK_PASSWORD, attrs)
if result == GnomeKeyring.Result.NO_MATCH:
raise PasswordDeleteError("Password not found")
for current in items:
result = GnomeKeyring.item_delete_sync(current.keyring,
current.item_id)
if result == GnomeKeyring.Result.CANCELLED:
raise PasswordDeleteError("Cancelled by user")
示例8: do_delete
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def do_delete(self, id):
keyring = GnomeKeyring.get_default_keyring_sync()[1]
GnomeKeyring.item_delete_sync(keyring, id)
示例9: remove
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def remove(self, key):
attrs = self._get_attrs(key)
result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.GENERIC_SECRET, attrs)
if result == GnomeKeyring.Result.OK:
GnomeKeyring.item_delete_sync(self._defaultKeyring, items[0].item_id)
示例10: del_from_keyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def del_from_keyring(keyring_id):
"""Delete an entry from the keyring."""
keyring = GnomeKeyring.get_default_keyring_sync()[1]
GnomeKeyring.item_delete_sync(keyring, keyring_id)
示例11: removeEncriptedFolder
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_delete_sync [as 别名]
def removeEncriptedFolder(self,epath):
id = self.find_folder(epath)
if id != None:
GnomeKeyring.item_delete_sync(self.keyring,id[0])
return True
return False