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


Python repository.Secret类代码示例

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


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

示例1: connect

 def connect(self, password):
     """
         Connect lastfm
         @param password as str/None
     """
     if self._goa:
         t = Thread(target=self._connect, args=('', '', True))
         t.daemon = True
         t.start()
     # Get username/password from GSettings/Secret
     elif Secret is not None and\
             Gio.NetworkMonitor.get_default().get_network_available():
         self._username = Lp().settings.get_value(
                                                'lastfm-login').get_string()
         if password is None:
             schema = Secret.Schema.new("org.gnome.Lollypop",
                                        Secret.SchemaFlags.NONE,
                                        SecretSchema)
             Secret.password_lookup(schema, SecretAttributes, None,
                                    self._on_password_lookup)
         else:
             t = Thread(target=self._connect, args=(self._username,
                                                    password, True))
             t.daemon = True
             t.start()
开发者ID:ferranroig,项目名称:lollypop,代码行数:25,代码来源:lastfm.py

示例2: set_account_password

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)
开发者ID:NightBuilder,项目名称:pithos,代码行数:7,代码来源:util.py

示例3: insert

    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
        )
开发者ID:bil-elmoussaoui,项目名称:Gnome-TwoFactorAuth,代码行数:26,代码来源:keyring.py

示例4: _update_lastfm_settings

 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)
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:26,代码来源:settings.py

示例5: testSynchronous

	def testSynchronous(self):
		attributes = { "number": "1", "string": "one", "even": "false" }

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual("111", password)

		deleted = Secret.password_remove_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(True, deleted)
开发者ID:Pusenka,项目名称:libsecret,代码行数:8,代码来源:test-remove-password.py

示例6: testSyncNotFound

	def testSyncNotFound(self):
		attributes = { "number": "11", "string": "one", "even": "true" }

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(None, password)

		deleted = Secret.password_remove_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(False, deleted)
开发者ID:Pusenka,项目名称:libsecret,代码行数:8,代码来源:test-remove-password.py

示例7: store_password

 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
开发者ID:benfitzpatrick,项目名称:rose,代码行数:10,代码来源:ws_client_auth.py

示例8: erase

def erase():
    attributes = get_attributes()

    if 'password' in attributes:
        del attributes['password']

    Secret.password_clear_sync(
            GIT_CREDENTIALS_SCHEMA,
            attributes,
            None
            )
开发者ID:timhughes,项目名称:git-credential-libsecret,代码行数:11,代码来源:git-credential-libsecret.py

示例9: setTokens

    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
                     )
开发者ID:AmmarAhmed01,项目名称:gnome-gmail,代码行数:12,代码来源:gnomegmail.py

示例10: set_account_password

    def set_account_password(self, old_email, new_email, password, callback):
        def on_password_store_finish(source, result, data):
            try:
                success = Secret.password_store_finish(result)
            except GLib.Error as e:
                logging.error('Failed to store password, Error: {}'.format(e))
                success = False
            if callback:
                callback(success)

        def on_password_clear_finish(source, result, data):
            try:
                password_removed = Secret.password_clear_finish(result)
                if password_removed:
                    logging.debug('Cleared password for: {}'.format(old_email))
                else:
                    logging.debug('No password found to clear for: {}'.format(old_email))
            except GLib.Error as e:
                logging.error('Failed to clear password for: {}, Error: {}'.format(old_email, e))
                if callback:
                    callback(False)
            else:
                Secret.password_store(
                    self._account_schema,
                    {'email': new_email},
                    self._current_collection,
                    'Pandora Account',
                    password,
                    None,
                    on_password_store_finish,
                    None,
                )

        if old_email and old_email != new_email:
            Secret.password_clear(
                self._account_schema,
                {'email': old_email},
                None,
                on_password_clear_finish,
                None,
            )

        else:
            Secret.password_store(
                self._account_schema,
                {'email': new_email},
                self._current_collection,
                'Pandora Account',
                password,
                None,
                on_password_store_finish,
                None,
            )
开发者ID:JasonLG1979,项目名称:pithos,代码行数:53,代码来源:util.py

示例11: testValueGet

	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")
开发者ID:Arkhont,项目名称:libsecret,代码行数:12,代码来源:test-unstable.py

示例12: testAsynchronous

	def testAsynchronous(self):
		loop = GLib.MainLoop(None)

		def on_result_ready(source, result, unused):
			loop.quit()
			password = Secret.password_lookup_finish(result)
			self.assertEquals("222", password)

		Secret.password_lookup (STORE_SCHEMA, { "number": "2", "string": "two" },
		                        None, on_result_ready, None)

		loop.run()
开发者ID:Distrotech,项目名称:libsecret,代码行数:12,代码来源:test-lookup-password.py

示例13: testAsyncNotFound

	def testAsyncNotFound(self):
		loop = GLib.MainLoop(None, False)

		def on_result_ready(source, result, unused):
			loop.quit()
			password = Secret.password_lookup_finish(result)
			self.assertEquals(None, password)

		Secret.password_lookup (STORE_SCHEMA, { "number": "7", "string": "five" },
		                        None, on_result_ready, None)

		loop.run()
开发者ID:Pusenka,项目名称:libsecret,代码行数:12,代码来源:test-lookup-password.py

示例14: testAsynchronous

	def testAsynchronous(self):
		loop = GLib.MainLoop(None, False)

		def on_result_ready(source, result, unused):
			loop.quit()
			deleted = Secret.password_remove_finish(result)
			self.assertEquals(True, deleted)

		Secret.password_remove(STORE_SCHEMA, { "number": "2", "string": "two" },
		                       None, on_result_ready, None)

		loop.run()
开发者ID:Pusenka,项目名称:libsecret,代码行数:12,代码来源:test-remove-password.py

示例15: testSynchronous

	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)
开发者ID:Pusenka,项目名称:libsecret,代码行数:12,代码来源:test-store-password.py


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