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


Python GnomeKeyring.lock_sync方法代码示例

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


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

示例1: test_create_lock

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import lock_sync [as 别名]
    def test_create_lock(self):
        '''create_sync() and locking/unlocking'''

        # create
        self.assertEqual(GnomeKeyring.create_sync(TEST_KEYRING, TEST_PWD),
                GnomeKeyring.Result.OK)
        (result, info) = GnomeKeyring.get_info_sync(TEST_KEYRING)
        self.assertEqual(result, GnomeKeyring.Result.OK)
        self.assertFalse(info.get_is_locked())

        # try to create already existing ring
        self.assertEqual(GnomeKeyring.create_sync(TEST_KEYRING, TEST_PWD),
                GnomeKeyring.Result.KEYRING_ALREADY_EXISTS)

        # lock
        self.assertEqual(GnomeKeyring.lock_sync(TEST_KEYRING),
                GnomeKeyring.Result.OK)
        self.assertTrue(GnomeKeyring.get_info_sync(TEST_KEYRING)[1].get_is_locked())

        # unlock with wrong password
        self.assertEqual(GnomeKeyring.unlock_sync(TEST_KEYRING, 'h4ck'),
                GnomeKeyring.Result.IO_ERROR)

        # unlock with correct password
        self.assertEqual(GnomeKeyring.unlock_sync(TEST_KEYRING, TEST_PWD),
                GnomeKeyring.Result.OK)
开发者ID:Bchelz,项目名称:libgnome-keyring,代码行数:28,代码来源:test-gi.py

示例2: lock

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import lock_sync [as 别名]
	def lock(self):
		result = GnomeKeyring.lock_sync(self.keyring)
		if result == GnomeKeyring.Result.OK:
			return True
		return False		
开发者ID:atareao,项目名称:cryptfolder-indicator,代码行数:7,代码来源:cfkeyringmanager.py

示例3: compile

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import lock_sync [as 别名]
        import getpass
        result = gkr.unlock_sync('login',
                                 getpass.getpass(prompt='Enter password for '
                                                 'login keyring: '))
        if result == gkr.Result.IO_ERROR:  # Incorrect password
            sys.exit(1)

    # Connect to libsecret
    service = Secret.Service.get_sync(Secret.ServiceFlags.OPEN_SESSION |
                                      Secret.ServiceFlags.LOAD_COLLECTIONS)
    collections = service.get_collections()

    # Search the default keyring
    items = service.unlock_sync(collections, None)[1][0].get_items()

    # Match the item's name using the search string as a regular expression
    found = [i for i in items if compile(sys.argv[1]).search(i.get_label())]

    if len(found):
        # Prompt the user to display any results. Use curses.wrapper to ensure
        # things are taken care of in case of a KeyboardInterrupt or other
        # exception, and that the screen is wiped afterwards.
        curses.wrapper(display_results, found)
    else:
        # Helpful feedback
        print("No matches for search term '{}'.".format(sys.argv[1]))

    # Relock the keyring if necessary
    if was_locked:
        gkr.lock_sync(KEYRING)
开发者ID:khaeru,项目名称:scripts,代码行数:32,代码来源:gk-query.py


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