本文整理汇总了Python中gi.repository.GnomeKeyring.is_available方法的典型用法代码示例。如果您正苦于以下问题:Python GnomeKeyring.is_available方法的具体用法?Python GnomeKeyring.is_available怎么用?Python GnomeKeyring.is_available使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GnomeKeyring
的用法示例。
在下文中一共展示了GnomeKeyring.is_available方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import is_available [as 别名]
def __init__(self):
self.loginDetails = False
if gk.is_available() is True:
if "Gusic" in gk.list_keyring_names_sync()[1]:
self.keyring = gk.list_item_ids_sync("Gusic")[1]
self.loginDetails = self._get_first_key("Gusic")
else:
gk.create_sync("Gusic", "Gusic")
示例2: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import is_available [as 别名]
def __init__(self):
self._protocol = "network"
self._key = gk.ItemType.NETWORK_PASSWORD
if not gk.is_available():
raise KeyringException("The Gnome keyring is not available")
logger.debug("GnomeKeyring is available")
self.loaded = False
self.lock = threading.RLock()
if not self.loaded:
(result, keyring_names) = gk.list_keyring_names_sync()
if self._KEYRING_NAME not in keyring_names:
logger.error("Error getting the gnome keyring. We'll try to create it: %s")
logger.debug("Creating keyring " + self._KEYRING_NAME)
gk.create_sync(self._KEYRING_NAME, None)
self.loaded = True
示例3: list_item_ids_sync
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import is_available [as 别名]
# 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])
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(''))
#
# main
#
if not GnomeKeyring.is_available():
print('GNOME keyring not available', file=sys.stderr)
sys.exit(0)
unittest.main()
示例4: print
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import is_available [as 别名]
import os
import ConfigParser
from datetime import datetime
from utils import APP_NAME, LOCALE_DIR
import gettext
gettext.bindtextdomain(APP_NAME, LOCALE_DIR)
gettext.textdomain(APP_NAME)
_ = gettext.gettext
try:
from gi.repository import GnomeKeyring
USE_GNOME_KEYRING = GnomeKeyring.is_available()
KEYRING_NAME = 'login' # default keyring that gets unlocked normally when the user starts the session
GUIFINETLOGINKEYNAME = 'guifinetlogin'
print(_('Use GNOME Keyring: {}').format(USE_GNOME_KEYRING))
GnomeKeyring.unlock_sync(KEYRING_NAME, None)
except ImportError:
print(_('GNOME Keyring dependency not available'))
print(_('Using plain text configuration files instead'))
USE_GNOME_KEYRING = False
class GuifinetStudioConfig:
CONFIG_DIR = os.path.expanduser('~/.config/guifinetstudio')
CACHE_DIR = os.path.expanduser('~/.cache/guifinetstudio')
CONFIG_FILENAME = os.path.join(CONFIG_DIR, 'config')