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


Python GnomeKeyring.result_to_message方法代码示例

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


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

示例1: test_result_str

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

示例2: __init__

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import result_to_message [as 别名]
    def __init__(self):
        self.keyring_item = None

        self.keyring_attributes = GnomeKeyring.attribute_list_new()
        GnomeKeyring.attribute_list_append_string(self.keyring_attributes,
                            "rhythmbox-plugin",
                            "vkontakte")
        (result, items) = GnomeKeyring.find_items_sync(GnomeKeyring.ItemType.GENERIC_SECRET,
                                self.keyring_attributes)
        if result == GnomeKeyring.Result.OK and len(items) != 0:
            (result, item) = GnomeKeyring.item_get_info_sync(None, items[0].item_id)
            if result == GnomeKeyring.Result.OK:
                self.keyring_item = item
            else:
                print "Couldn't get keyring item: " + GnomeKeyring.result_to_message(result)
        else:
            print "couldn't search keyring items: " + GnomeKeyring.result_to_message(result)
开发者ID:sancheolz,项目名称:rhythmbox-vkontakte,代码行数:19,代码来源:VkontakteAccount.py

示例3: setup_gnome_keyring

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import result_to_message [as 别名]
def setup_gnome_keyring():
    """
    Provide clean login Gnome keyring (removes the previous one
    beforehand, if there is a one).
    """
    try:
        # Delete originally stored password
        (response, keyring) = GnomeKeyring.get_default_keyring_sync()
        log.debug('get_info default: %s, %s' % (response, keyring))
        if response == GnomeKeyring.Result.OK:
            if keyring is not None:
                delete_response = GnomeKeyring.delete_sync(keyring)
                log.debug('delete default: %s' % delete_response)
                assert delete_response == GnomeKeyring.Result.OK, \
                    "Delete failed: %s" % delete_response
            response, keyring = GnomeKeyring.get_info_sync('login')
            if response == GnomeKeyring.Result.OK:
                if keyring is not None:
                    delete_response = GnomeKeyring.delete_sync('login')
                    log.debug('delete login: %s' % delete_response)
                    assert delete_response == GnomeKeyring.Result.OK, \
                        "Delete failed: %s" % delete_response
            elif response != GnomeKeyring.Result.NO_SUCH_KEYRING:
                raise IOError(
                    'Unexpected error when manipulating login keyring')

            # This is result of the underlying DBus error:
            # CKR_WRAPPED_KEY_INVALID, CKR_WRAPPED_KEY_LEN_RANGE,
            # CKR_MECHANISM_PARAM_INVALID
            # So, failed either
            # * egg_padding_pkcs7_unpad
            #   (gnome-keyring/egg/egg-padding.c)
            # * gkm_aes_mechanism_unwrap
            #   (gnome-keyring/pkcs11/gkm/gkm-aes-mechanism.c)
            # * gkm_dh_mechanism_derive
            #   (gnome-keyring/pkcs11/gkm/gkm-dh-mechanism.c)
            # * gkm_null_mechanism_unwrap or gkm_null_mechanism_wrap
            #   (gnome-keyring/pkcs11/gkm/gkm-null-mechanism.c)
            create_response = GnomeKeyring.create_sync('login', 'redhat')
            log.debug('create login: %s' % create_response)
            if create_response != GnomeKeyring.Result.OK:
                raise IOError(
                    'Create failed: %s\n%s' %
                    (create_response,
                     GnomeKeyring.result_to_message(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", 'redhat')
        assert unlock_response == GnomeKeyring.Result.OK, \
            "Unlock failed: %s" % unlock_response
    except Exception as e:
        log.error("Exception while unlocking a keyring: %s", e.message)
        raise  # We shouldn’t let this exception evaporate
开发者ID:mkrajnak,项目名称:libreoffice-tests,代码行数:58,代码来源:__init__.py

示例4: update

# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import result_to_message [as 别名]
    def update(self, username, password):
        secret = '\n'.join((username, password))
        if self.keyring_item is not None:
            if secret == self.keyring_item.get_secret():
                print "account details not changed"
                return

        (result, id) = GnomeKeyring.item_create_sync(None,
                                 GnomeKeyring.ItemType.GENERIC_SECRET,
                                 "Rhythmbox: Vkontakte account information",
                                 self.keyring_attributes,
                                 secret,
                                 True)
        if result == GnomeKeyring.Result.OK:
            if self.keyring_item is None:
                (result, item) = GnomeKeyring.item_get_info_sync(None, id)
                if result == GnomeKeyring.Result.OK:
                    self.keyring_item = item
                else:
                    print "couldn't fetch keyring item: " + GnomeKeyring.result_to_message(result)
        else:
            print "couldn't create keyring item: " + GnomeKeyring.result_to_message(result)
开发者ID:sancheolz,项目名称:rhythmbox-vkontakte,代码行数:24,代码来源:VkontakteAccount.py


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