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


Python repository.GnomeKeyring类代码示例

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


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

示例1: test_item_create_info

    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,代码行数:26,代码来源:test-gi.py

示例2: get_master_key

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,代码行数:7,代码来源:client.py

示例3: get

	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,代码行数:26,代码来源:keyring.py

示例4: find_keyring_items

    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,代码行数:34,代码来源:PandoraConfigureDialog.py

示例5: test_find_items

    def test_find_items(self):
        '''find_items_sync()'''

        search_attrs = GnomeKeyring.Attribute.list_new()

        # no attributes, finds everything
        (result, items) = GnomeKeyring.find_items_sync(
                GnomeKeyring.ItemType.GENERIC_SECRET,
                search_attrs)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        print('(no attributes: %i matches) ' % len(items), end='', file=sys.stderr)
        for item in items:
            self.assertNotEqual(item.keyring, '')
            for attr in GnomeKeyring.Attribute.list_to_glist(item.attributes):
                self.assertTrue(attr.type in (GnomeKeyring.AttributeType.STRING,
                            GnomeKeyring.AttributeType.UINT32))
                self.assertEqual(type(attr.name), type(''))
                self.assertGreater(len(attr.name), 0)

                # check that we can get the value
                if attr.type == GnomeKeyring.AttributeType.STRING:
                    self.assertEqual(type(attr.get_string()), type(''))
                else:
                    self.assertTrue(isinstance(attr.get_uint32()), long)

        # search for unknown attribute, should have no results
        GnomeKeyring.Attribute.list_append_string(search_attrs, 'unknown!_attr', '')
        (result, items) = GnomeKeyring.find_items_sync(
                GnomeKeyring.ItemType.GENERIC_SECRET,
                search_attrs)
        self.assertEqual(result, GnomeKeyring.Result.NO_MATCH)
        self.assertEqual(len(items), 0)
开发者ID:Bchelz,项目名称:libgnome-keyring,代码行数:32,代码来源:test-gi.py

示例6: do_store

 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,代码行数:8,代码来源:gnome-keyring.py

示例7: test_result_str

    def test_result_str(self):
        '''result_to_message()'''

        self.assertEqual(GnomeKeyring.result_to_message(GnomeKeyring.Result.OK),
                '')
        self.assertEqual(
                type(GnomeKeyring.result_to_message(GnomeKeyring.Result.NO_SUCH_KEYRING)),
                type(''))
开发者ID:Bchelz,项目名称:libgnome-keyring,代码行数:8,代码来源:test-gi.py

示例8: set_credentials

 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,代码行数:8,代码来源:gm_notify_keyring.py

示例9: delete_credentials

 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)
开发者ID:balbusm,项目名称:gm-notify,代码行数:9,代码来源:gm_notify_keyring.py

示例10: _set_value_to_gnomekeyring

 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,代码行数:9,代码来源:gkrmanager.py

示例11: _migrate_keyring

	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)
开发者ID:Mailaender,项目名称:mailnag,代码行数:10,代码来源:credentialstore.py

示例12: put_in_keyring

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,代码行数:11,代码来源:keyring.py

示例13: __init__

	def __init__(self):
		self.KEYRING_ITEM_NAME = 'Mailnag password for %s://%[email protected]%s'
		
		(result, kr_name) = GnomeKeyring.get_default_keyring_sync()
		self._defaultKeyring = kr_name
		
		if self._defaultKeyring == None:
			self._defaultKeyring = 'login'

		result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)
		
		if (result != GnomeKeyring.Result.OK):
			raise Exception('Failed to unlock default keyring')
开发者ID:mikeit,项目名称:mailnag,代码行数:13,代码来源:keyring.py

示例14: __init__

	def __init__(self):
		(result, kr_name) = GnomeKeyring.get_default_keyring_sync()
		self._defaultKeyring = kr_name
		
		if self._defaultKeyring == None:
			self._defaultKeyring = 'login'

		result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)
		
		if result != GnomeKeyring.Result.OK:
			raise KeyringUnlockException('Failed to unlock default keyring')

		self._migrate_keyring()
开发者ID:Mailaender,项目名称:mailnag,代码行数:13,代码来源:credentialstore.py

示例15: before_all

def before_all(context):
    """Setup evolution stuff
    Being executed before all features
    """

    # Reset GSettings
    schemas = [x for x in Gio.Settings.list_schemas() if 'evolution' in x.lower()]
    for schema in schemas:
        os.system("gsettings reset-recursively %s" % schema)

    # Skip warning dialog
    os.system("gsettings set org.gnome.evolution.shell skip-warning-dialog true")
    # Show switcher buttons as icons (to minimize tree scrolling)
    os.system("gsettings set org.gnome.evolution.shell buttons-style icons")

    # Wait for things to settle
    sleep(0.5)

    # Skip dogtail actions to print to stdout
    config.logDebugToStdOut = False
    config.typingDelay = 0.2

    # Include assertion object
    context.assertion = dummy()

    # Kill initial setup
    os.system("killall /usr/libexec/gnome-initial-setup")

    # Delete existing ABRT problems
    if problem.list():
        [x.delete() for x in problem.list()]

    try:
        from gi.repository import GnomeKeyring
        # Delete originally stored password
        (response, keyring) = GnomeKeyring.get_default_keyring_sync()
        if response == GnomeKeyring.Result.OK:
            if keyring is not None:
                delete_response = GnomeKeyring.delete_sync(keyring)
                assert delete_response == GnomeKeyring.Result.OK, "Delete failed: %s" % delete_response
            create_response = GnomeKeyring.create_sync("login", 'gnome')
            assert create_response == GnomeKeyring.Result.OK, "Create failed: %s" % create_response
            set_default_response = GnomeKeyring.set_default_keyring_sync('login')
            assert set_default_response == GnomeKeyring.Result.OK, "Set default failed: %s" % set_default_response
        unlock_response = GnomeKeyring.unlock_sync("login", 'gnome')
        assert unlock_response == GnomeKeyring.Result.OK, "Unlock failed: %s" % unlock_response
    except Exception as e:
        print("Exception while unlocking a keyring: %s" % e.message)

    context.app = App('evolution')
开发者ID:fedora-desktop-tests,项目名称:evolution,代码行数:50,代码来源:environment.py


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