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


Python GnomeKeyring.list_item_ids_sync方法代码示例

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


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

示例1: get_master_key

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
def get_master_key():
    ids = GnomeKeyring.list_item_ids_sync(KEYRING)[1]
    for id in ids:
        info = GnomeKeyring.item_get_info_sync('login', id)[1]
        if info.get_display_name() == 'gpwg:masterkey':
            return info.get_secret()
    return None
开发者ID:FlorianLudwig,项目名称:gpwg,代码行数:9,代码来源:client.py

示例2: test_item_create_info

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
    def test_item_create_info(self):
        '''item_create_sync(),  item_get_info_sync(), list_item_ids_sync()'''

        self.assertEqual(GnomeKeyring.create_sync(TEST_KEYRING, TEST_PWD),
                GnomeKeyring.Result.OK)
        self.assertEqual(GnomeKeyring.get_info_sync(TEST_KEYRING)[0], GnomeKeyring.Result.OK)

        attrs = GnomeKeyring.Attribute.list_new()
        GnomeKeyring.Attribute.list_append_string(attrs, 'context', 'testsuite')
        GnomeKeyring.Attribute.list_append_uint32(attrs, 'answer', 42)

        (result, id) = GnomeKeyring.item_create_sync(TEST_KEYRING,
                GnomeKeyring.ItemType.GENERIC_SECRET, 'my_password', attrs,
                'my_secret', False)
        self.assertEqual(result, GnomeKeyring.Result.OK)

        # now query for it
        (result, info) = GnomeKeyring.item_get_info_sync(TEST_KEYRING, id)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertEqual(info.get_display_name(), 'my_password')
        self.assertEqual(info.get_secret(), 'my_secret')

        # list_item_ids_sync()
        (result, items) = GnomeKeyring.list_item_ids_sync(TEST_KEYRING)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertEqual(items, [id])
开发者ID:Bchelz,项目名称:libgnome-keyring,代码行数:28,代码来源:test-gi.py

示例3: _find

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
 def _find(self, displayName, keyring):
     item_keys = gk.list_item_ids_sync(keyring)
     for k in item_keys[1]:
         item_info = gk.item_get_info_sync(keyring, k)
         if item_info.get_display_name() == displayName:
             return (k, item_info.get_display_name(), item_info.get_secret())
     return False
开发者ID:subutux,项目名称:gusic,代码行数:9,代码来源:KeyRing.py

示例4: _get_first_key

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
 def _get_first_key(self, keyring):
     item_keys = gk.list_item_ids_sync(keyring)
     if len(item_keys[1]) > 0:
         item_info = gk.item_get_info_sync(keyring, item_keys[1][0])
         return (item_info[1].get_display_name(), item_info[1].get_secret())
     else:
         return False
开发者ID:subutux,项目名称:gusic,代码行数:9,代码来源:KeyRing.py

示例5: set

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
	def set(self, protocol, user, server, password):
		if password != '':
			displayNameDict = {}
			(result, ids) = GnomeKeyring.list_item_ids_sync(self._defaultKeyring)
			for identity in ids:
				(result, item) = GnomeKeyring.item_get_info_sync(self._defaultKeyring, identity)
				displayNameDict[item.get_display_name()] = identity

			attrs = GnomeKeyring.Attribute.list_new()
			GnomeKeyring.Attribute.list_append_string(attrs, 'application',	'Mailnag')
			GnomeKeyring.Attribute.list_append_string(attrs, 'protocol',	protocol)
			GnomeKeyring.Attribute.list_append_string(attrs, 'user',		user)
			GnomeKeyring.Attribute.list_append_string(attrs, 'server',		server)
			
			if self.KEYRING_ITEM_NAME % (protocol, user, server) in displayNameDict:
				(result, item) = GnomeKeyring.item_get_info_sync(self._defaultKeyring, \
					displayNameDict[self.KEYRING_ITEM_NAME % \
					(protocol, user, server)])
				
				if password != item.get_secret():
					GnomeKeyring.item_create_sync(self._defaultKeyring, \
						GnomeKeyring.ItemType.GENERIC_SECRET, \
						self.KEYRING_ITEM_NAME % (protocol, user, server), \
						attrs, password, True)
			else:
				GnomeKeyring.item_create_sync(self._defaultKeyring, \
					GnomeKeyring.ItemType.GENERIC_SECRET, \
					self.KEYRING_ITEM_NAME % (protocol, user, server), \
					attrs, password, True)
开发者ID:mikeit,项目名称:mailnag,代码行数:31,代码来源:keyring.py

示例6: get

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
	def get(self, protocol, user, server):
		(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

			if self.KEYRING_ITEM_NAME % (protocol, user, server) in displayNameDict:
				(result, item) = GnomeKeyring.item_get_info_sync(self._defaultKeyring, \
					displayNameDict[self.KEYRING_ITEM_NAME % \
					(protocol, user, server)])

				if item.get_secret() != '':
					return item.get_secret()
				else:
					# DEBUG print "Keyring.get(): No Keyring Password for %s://%[email protected]%s." % (protocol, user, server)
					return ''

			else:
				# DEBUG print "Keyring.get(): %s://%[email protected]%s not in Keyring." % (protocol, user, server)
				return ''

		else:
			# DEBUG print "Keyring.get(): Neither default- nor 'login'-Keyring available."
			return ''
开发者ID:mikeit,项目名称:mailnag,代码行数:28,代码来源:keyring.py

示例7: remove_by_id

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_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)))
开发者ID:emersion,项目名称:Gnome-TwoFactorAuth,代码行数:27,代码来源:database.py

示例8: __init__

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
    def __init__(self):
        self.loginDetails = False
        if gk.is_available() is True:
            if "Gusic" in gk.list_keyring_names_sync()[1]:
                self.keyring = gk.list_item_ids_sync("Gusic")[1]

                self.loginDetails = self._get_first_key("Gusic")

            else:
                gk.create_sync("Gusic", "Gusic")
开发者ID:subutux,项目名称:gusic,代码行数:12,代码来源:KeyRing.py

示例9: import_keyrings

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
def import_keyrings(from_file):
    with open(from_file, "r") as f:
        keyrings = json.loads(f)

    for keyring_name, keyring_items in list(keyrings.items()):
        try:
            existing_ids = GnomeKeyring.list_item_ids_sync(keyring_name)
        except GnomeKeyring.NoSuchKeyringError:
            sys.stderr.write("No keyring '%s' found. Please create this keyring first" % keyring_name)
            sys.exit(1)

        existing_items = [get_item(keyring_name, id) for id in existing_ids]
        existing_items = [i for i in existing_items if i is not None]

        for item in keyring_items:
            if any(items_roughly_equal(item, i) for i in existing_items):
                print("Skipping %s because it already exists" % item['display_name'])
            else:
                nearly = [i for i in existing_items if items_roughly_equal(i, item, ignore_secret=True)]
                if nearly:
                    print("Existing secrets found for '%s'" % item['display_name'])
                    for i in nearly:
                        print(" " + i['secret'])

                    print("So skipping value from '%s':" % from_file)
                    print(" " + item['secret'])
                else:
                    schema = item['attributes']['xdg:schema']
                    item_type = None
                    if schema ==  'org.freedesktop.Secret.Generic':
                        item_type = GnomeKeyring.ITEM_GENERIC_SECRET
                    elif schema == 'org.gnome.keyring.Note':
                        item_type = GnomeKeyring.ITEM_NOTE
                    elif schema == 'org.gnome.keyring.NetworkPassword':
                        item_type == GnomeKeyring.ITEM_NETWORK_PASSWORD

                    if item_type is not None:
                        item_id = GnomeKeyring.item_create_sync(keyring_name,
                                                                item_type,
                                                                item['display_name'],
                                                                fix_attributes(item['attributes']),
                                                                item['secret'],
                                                                False)
                        print("Copying secret %s" % item['display_name'])
                    else:
                        print("Can't handle secret '%s' of type '%s', skipping" % (item['display_name'], schema))
开发者ID:nicklasb,项目名称:gnome-keyring-import-export,代码行数:48,代码来源:gnome_keyring_import_export.py

示例10: remove

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_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])
开发者ID:mikeit,项目名称:mailnag,代码行数:21,代码来源:keyring.py

示例11: dump

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
 def dump(self, print_passwords=False):
     """Get all keyring entries (with or without passwords)
     """
     from gi.repository import GnomeKeyring
     dump = ""
     (result, ids) = GnomeKeyring.list_item_ids_sync(self.KEYRING_NAME)
     for id in ids:	
         (result, item) = GnomeKeyring.item_get_info_sync(self.KEYRING_NAME, id)
         if result == GnomeKeyring.Result.IO_ERROR:
             return None
         if result == GnomeKeyring.Result.NO_MATCH:
             return None
         if result == GnomeKeyring.Result.CANCELLED:
             # The user pressed "Cancel" when prompted to unlock their keyring.
             return None
         dump += item.get_display_name()
         if print_passwords:
             dump += " = " + item.get_secret()
         dump += "\n"
     return dump
开发者ID:pschmitt,项目名称:python-keyring-lib-keyring,代码行数:22,代码来源:Gnome.py

示例12: len

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import list_item_ids_sync [as 别名]
import sys
from gi.repository import GnomeKeyring as gk

if len(sys.argv) < 3:
    print >> sys.stderr, "invalid arguments\n    python gnomekeyring.py keyring itemname"
    exit(1)

ringname = sys.argv[1]
keyname = sys.argv[2]

(result, keyrings) = gk.list_keyring_names_sync()
if not ringname in keyrings:
    print >> sys.stderr, "keyring '%s' not found" % ringname
    exit(2)


result = gk.unlock_sync(ringname, None)
if not result == gk.Result.OK:
    print >> sys.stderr, "keyring '%s' is locked" % ringname
    exit(3)

(result, ids) = gk.list_item_ids_sync(ringname)
for id in ids:
    (result, info) = gk.item_get_info_sync(ringname, id)
    if info.get_display_name() == keyname:
        print info.get_secret()
        exit(0)

print >> sys.stderr, "keyname '%s' in '%s' not found" % (keyname, ringname)
exit(4)
开发者ID:swick,项目名称:irssi-passwd,代码行数:32,代码来源:gnomekeyring.py


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