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


Python Secret.password_store方法代码示例

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


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

示例1: set_account_password

# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store [as 别名]
    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,代码行数:55,代码来源:util.py

示例2: testAsynchronous

# 需要导入模块: from gi.repository import Secret [as 别名]
# 或者: from gi.repository.Secret import password_store [as 别名]
	def testAsynchronous(self):
		attributes = { "number": "888", "string": "eight", "even": "true" }

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

		loop = GLib.MainLoop(None, False)

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

		Secret.password_store(STORE_SCHEMA, attributes, None, "The number eight", "888",
		                      None, on_result_ready, None)

		loop.run()

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual("888", password)
开发者ID:Pusenka,项目名称:libsecret,代码行数:22,代码来源:test-store-password.py


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