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


Python GnomeKeyring.item_create_sync方法代码示例

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


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

示例1: set

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_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

示例2: set_credentials

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
 def set_credentials(self, user, pw):
     attrs = attributes({
             "user": user,
             "server": self._server,
             "protocol": self._protocol,
         })
     GnomeKeyring.item_create_sync(self._keyring,
             GnomeKeyring.ItemType.NETWORK_PASSWORD, self._name, attrs, pw, True)
开发者ID:balbusm,项目名称:gm-notify,代码行数:10,代码来源:gm_notify_keyring.py

示例3: do_store

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
 def do_store(self, id, username, password):
     GnomeKeyring.create_sync("liferea", None)
     attrs = GnomeKeyring.Attribute.list_new()
     GnomeKeyring.Attribute.list_append_string(attrs, "id", id)
     GnomeKeyring.Attribute.list_append_string(attrs, "user", username)
     GnomeKeyring.item_create_sync(
         "liferea", GnomeKeyring.ItemType.GENERIC_SECRET, repr(id), attrs, "@@@".join([username, password]), True
     )
开发者ID:skagedal,项目名称:liferea,代码行数:10,代码来源:gnome-keyring.py

示例4: get_keyring_password

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
def get_keyring_password():
    GnomeKeyring.unlock_sync("login", None)
    attrs = GnomeKeyring.Attribute.list_new()
    GnomeKeyring.Attribute.list_append_string(attrs, "id", "resnet")
    result, value = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.GENERIC_SECRET, attrs)
    if result == GnomeKeyring.Result.OK:
        return value[0].secret
    elif result == GnomeKeyring.Result.NO_MATCH:
        # Password not found, prompt to add new one
        print("Password not found in keyring")
        password = getpass.getpass("OSU Login Password: ")
        GnomeKeyring.item_create_sync("login", GnomeKeyring.ItemType.GENERIC_SECRET, "resnet", attrs, password, True)
        return password
    elif result != GnomeKeyring.Result.OK:
        return None
开发者ID:oslerw,项目名称:OSU-ResNet-Login,代码行数:17,代码来源:resnet.py

示例5: find_keyring_items

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
    def find_keyring_items(self):
        attrs = GnomeKeyring.Attribute.list_new()
        GnomeKeyring.Attribute.list_append_string(attrs, 'rhythmbox-plugin', 'pandora')
        result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.GENERIC_SECRET, attrs)

        if (result is None or result is GnomeKeyring.Result.OK) and len(items) != 0: # Got list of search results
            self.__keyring_data['id'] = items[0].item_id
            result, item = GnomeKeyring.item_get_info_sync(None, self.__keyring_data['id'])
            if result is None or result is GnomeKeyring.Result.OK: # Item retrieved successfully
                self.__keyring_data['item'] = item
                self.fill_account_details()
            else:
                print("Couldn't retrieve keyring item: " + str(result))

        elif result == GnomeKeyring.Result.NO_MATCH or len(items) == 0: # No items were found, so we'll create one
            result, id = GnomeKeyring.item_create_sync(
                                None,
                                GnomeKeyring.ItemType.GENERIC_SECRET,
                                "Rhythmbox: Pandora account information",
                                attrs,
                                "", # Empty secret for now
                                True)
            if result is None or result is GnomeKeyring.Result.OK: # Item successfully created
                self.__keyring_data['id'] = id
                result, item = GnomeKeyring.item_get_info_sync(None, id)
                if result is None: # Item retrieved successfully
                    self.__keyring_data['item'] = item
                    self.fill_account_details()
                else:
                    print("Couldn't retrieve keyring item: " + str(result))
            else:
                print("Couldn't create keyring item: " + str(result))
        else: # Some other error occurred
            print("Couldn't access keyring: " + str(result))
开发者ID:bcbnz,项目名称:rhythmbox-pandora,代码行数:36,代码来源:PandoraConfigureDialog.py

示例6: test_item_create_info

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_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

示例7: set

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
	def set(self, key, secret):
		if secret == '':
			return
		
		attrs = self._get_attrs(key)
		
		existing_secret = ''
		result, items = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.GENERIC_SECRET, attrs)
		
		if result == GnomeKeyring.Result.OK:
			existing_secret = items[0].secret
		
		if existing_secret != secret:
			GnomeKeyring.item_create_sync(self._defaultKeyring, \
					GnomeKeyring.ItemType.GENERIC_SECRET, key, \
					attrs, secret, True)
开发者ID:Mailaender,项目名称:mailnag,代码行数:18,代码来源:credentialstore.py

示例8: _set_value_to_gnomekeyring

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
 def _set_value_to_gnomekeyring(self, name, value):
     """Store a value in the keyring."""
     attributes = GnomeKeyring.Attribute.list_new()
     GnomeKeyring.Attribute.list_append_string(attributes, "id", str(name))
     keyring = GnomeKeyring.get_default_keyring_sync()[1]
     value = GnomeKeyring.item_create_sync(
         keyring, GnomeKeyring.ItemType.GENERIC_SECRET, "%s preferences" % (com.APP), attributes, str(value), True
     )
     return value[1]
开发者ID:atareao,项目名称:cryptfolder-indicator,代码行数:11,代码来源:gkrmanager.py

示例9: createEncriptedFolder

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
	def createEncriptedFolder(self,epath,password):
		attributes = GnomeKeyring.Attribute.list_new()
		GnomeKeyring.Attribute.list_append_string(attributes, 'appid', APPID)
		GnomeKeyring.Attribute.list_append_string(attributes, 'encfs-path', str(epath))
		result = GnomeKeyring.item_create_sync (self.keyring, \
		GnomeKeyring.ItemType.GENERIC_SECRET, \
		'Encrypted folder %s'%(epath),attributes, password,True)[0]
		if result == GnomeKeyring.Result.OK:
			return True
		return False
开发者ID:atareao,项目名称:cryptfolder-indicator,代码行数:12,代码来源:cfkeyringmanager.py

示例10: set_password

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
    def set_password(self, name, password, userid=""):
        attrs = GnomeKeyring.Attribute.list_new()
        GnomeKeyring.Attribute.list_append_string(attrs, "backend", name)
        result, password_id = GnomeKeyring.item_create_sync(
            self.keyring, GnomeKeyring.ItemType.GENERIC_SECRET, name, attrs, password, True
        )

        if result != GnomeKeyring.Result.OK:
            raise Exception("Can't create a new password, error=%s" % result)

        return password_id
开发者ID:abseabse,项目名称:gtg,代码行数:13,代码来源:keyring.py

示例11: put_in_keyring

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
def put_in_keyring(acctid, name, value):
  """Store a value in the keyring."""
  id = "%s/%s" % (acctid, name)
  attributes = GnomeKeyring.Attribute.list_new()
  GnomeKeyring.Attribute.list_append_string(attributes, 'id', str(id))
  keyring = GnomeKeyring.get_default_keyring_sync()[1]
  value = GnomeKeyring.item_create_sync(
    keyring, GnomeKeyring.ItemType.GENERIC_SECRET,
    "Gwibber preference: %s" % id,
    attributes, str(value), True)
  return value[1]
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:13,代码来源:keyring.py

示例12: _create_keyring_item_info

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
 def _create_keyring_item_info(self, secret):
     result, item_id = GnomeKeyring.item_create_sync(
                             GnomeCredentialStore.KEYRING_NAME,
                             GnomeKeyring.ItemType.GENERIC_SECRET,
                             repr(GnomeCredentialStore.ITEM_ATTR_ID),
                             self.item_attrs,
                             secret,
                             True)
     if result != GnomeKeyring.Result.OK:
         logger.debug("Failed to create keyring item: %s" % result)
         return None
     logger.debug("Successfully created keyring item info with item id: %s " % item_id)
     return item_id
开发者ID:kennydo,项目名称:airbears-supplicant-gtk,代码行数:15,代码来源:credentialstore.py

示例13: add_account

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
 def add_account(self, name, secret_code, image):
     """
         Add an account to accounts table
         :param name: (str) account name
         :param secret_code: (str) ASCII Secret code
         :param image: image path or icon name
         :return:
     """
     encrypted_secret = sha256(secret_code.encode('utf-8')).hexdigest()
     t = (name, encrypted_secret, image,)
     query = "INSERT INTO accounts (name, secret_code, image) VALUES (?, ?, ?)"
     try:
         GK.create_sync("TwoFactorAuth", None)
         attr = GK.Attribute.list_new()
         GK.Attribute.list_append_string(attr, 'id', encrypted_secret)
         GK.Attribute.list_append_string(attr, 'secret_code', secret_code)
         GK.item_create_sync("TwoFactorAuth", GK.ItemType.GENERIC_SECRET, repr(encrypted_secret), attr,
                             secret_code, False)
         self.conn.execute(query, t)
         self.conn.commit()
     except Exception as e:
         logging.error("SQL: Couldn't add a new account : %s ", str(e))
开发者ID:emersion,项目名称:Gnome-TwoFactorAuth,代码行数:24,代码来源:database.py

示例14: import_keyrings

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_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

示例15: store_credentials

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import item_create_sync [as 别名]
    def store_credentials(self, acc, credentials):
        self.lock.acquire()
        try:
            logger.debug("Storing credentials with gnome keyring for account %s" % (acc.get_name()))
            #Remove the old info and create a new item with the new info
            self.remove_credentials(acc)

            attrs = gk.Attribute.list_new()
            gk.Attribute.list_append_string(attrs, 'account_name', acc.get_name())
            gk.Attribute.list_append_string(attrs, 'username', credentials.username)
            
            (result, id) = gk.item_create_sync(self._KEYRING_NAME, \
                 gk.ItemType.NETWORK_PASSWORD, acc.get_name(), attrs, credentials.password, True)
            if result != gk.Result.OK:
                raise Exception("Gnome Keyring return the error code: %i" % result)
            logger.debug("credentials stored with id: %i" % (id))
        finally:
            self.lock.release()
开发者ID:akwala,项目名称:cloud-services-notifications,代码行数:20,代码来源:gkeyring.py


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