本文整理汇总了Python中gi.repository.GnomeKeyring.get_default_keyring_sync方法的典型用法代码示例。如果您正苦于以下问题:Python GnomeKeyring.get_default_keyring_sync方法的具体用法?Python GnomeKeyring.get_default_keyring_sync怎么用?Python GnomeKeyring.get_default_keyring_sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GnomeKeyring
的用法示例。
在下文中一共展示了GnomeKeyring.get_default_keyring_sync方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: priority
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def priority(cls):
if 'GnomeKeyring' not in globals():
raise RuntimeError("GnomeKeyring module required")
result = GnomeKeyring.get_default_keyring_sync()[0]
if result != GnomeKeyring.Result.OK:
raise RuntimeError(result.value_name)
return 1
示例2: _set_value_to_gnomekeyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def _set_value_to_gnomekeyring(self, name, value):
"""Store a value in the keyring."""
attributes = GnomeKeyring.Attribute.list_new()
GnomeKeyring.Attribute.list_append_string(attributes, "id", str(name))
keyring = GnomeKeyring.get_default_keyring_sync()[1]
value = GnomeKeyring.item_create_sync(
keyring, GnomeKeyring.ItemType.GENERIC_SECRET, "%s preferences" % (com.APP), attributes, str(value), True
)
return value[1]
示例3: setup_gnome_keyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [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
示例4: put_in_keyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def put_in_keyring(acctid, name, value):
"""Store a value in the keyring."""
id = "%s/%s" % (acctid, name)
attributes = GnomeKeyring.Attribute.list_new()
GnomeKeyring.Attribute.list_append_string(attributes, 'id', str(id))
keyring = GnomeKeyring.get_default_keyring_sync()[1]
value = GnomeKeyring.item_create_sync(
keyring, GnomeKeyring.ItemType.GENERIC_SECRET,
"Gwibber preference: %s" % id,
attributes, str(value), True)
return value[1]
示例5: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def __init__(self):
(result, kr_name) = GnomeKeyring.get_default_keyring_sync()
self._defaultKeyring = kr_name
if self._defaultKeyring == None:
self._defaultKeyring = 'login'
result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)
if result != GnomeKeyring.Result.OK:
raise KeyringUnlockException('Failed to unlock default keyring')
self._migrate_keyring()
示例6: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def __init__(self):
self.KEYRING_ITEM_NAME = 'Mailnag password for %s://%[email protected]%s'
(result, kr_name) = GnomeKeyring.get_default_keyring_sync()
self._defaultKeyring = kr_name
if self._defaultKeyring == None:
self._defaultKeyring = 'login'
result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)
if (result != GnomeKeyring.Result.OK):
raise Exception('Failed to unlock default keyring')
示例7: before_all
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def before_all(context):
"""Setup evolution stuff
Being executed before all features
"""
# Reset GSettings
schemas = [x for x in Gio.Settings.list_schemas() if 'evolution' in x.lower()]
for schema in schemas:
os.system("gsettings reset-recursively %s" % schema)
# Skip warning dialog
os.system("gsettings set org.gnome.evolution.shell skip-warning-dialog true")
# Show switcher buttons as icons (to minimize tree scrolling)
os.system("gsettings set org.gnome.evolution.shell buttons-style icons")
# Wait for things to settle
sleep(0.5)
# Skip dogtail actions to print to stdout
config.logDebugToStdOut = False
config.typingDelay = 0.2
# Include assertion object
context.assertion = dummy()
# Kill initial setup
os.system("killall /usr/libexec/gnome-initial-setup")
# Delete existing ABRT problems
if problem.list():
[x.delete() for x in problem.list()]
try:
from gi.repository import GnomeKeyring
# Delete originally stored password
(response, keyring) = GnomeKeyring.get_default_keyring_sync()
if response == GnomeKeyring.Result.OK:
if keyring is not None:
delete_response = GnomeKeyring.delete_sync(keyring)
assert delete_response == GnomeKeyring.Result.OK, "Delete failed: %s" % delete_response
create_response = GnomeKeyring.create_sync("login", 'gnome')
assert create_response == GnomeKeyring.Result.OK, "Create failed: %s" % 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", 'gnome')
assert unlock_response == GnomeKeyring.Result.OK, "Unlock failed: %s" % unlock_response
except Exception as e:
print("Exception while unlocking a keyring: %s" % e.message)
context.app = App('evolution')
示例8: keyring_name
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def keyring_name(self):
system_default = GnomeKeyring.get_default_keyring_sync()[1]
return self.KEYRING_NAME or system_default
示例9: do_delete
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def do_delete(self, id):
keyring = GnomeKeyring.get_default_keyring_sync()[1]
GnomeKeyring.item_delete_sync(keyring, id)
示例10: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def __init__(self):
super(Keyring, self).__init__()
if not hasattr(self, "keyring"):
result, self.keyring = GnomeKeyring.get_default_keyring_sync()
if result != GnomeKeyring.Result.OK:
raise Exception("Can't get default keyring, error=%s" % result)
示例11: insert_master_key
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
#!/usr/bin/python
# copyright 2012 Florian Ludwig <[email protected]>
import os
import socket
from gi.repository import GnomeKeyring, GLib
import glib
import gpwg
SOCKET_PATH = '/tmp/gpwg'
KEYRING = GnomeKeyring.get_default_keyring_sync()[1]
def insert_master_key(master_key):
GnomeKeyring.item_create_sync(KEYRING, GnomeKeyring.ItemType.GENERIC_SECRET, 'gpwg:masterkey', GLib.Array(), master_key, 1)
def get_master_key():
ids = GnomeKeyring.list_item_ids_sync(KEYRING)[1]
for id in ids:
info = GnomeKeyring.item_get_info_sync('login', id)[1]
if info.get_display_name() == 'gpwg:masterkey':
return info.get_secret()
return None
def main():
GLib.set_application_name('GNOME password generator')
master_key = get_master_key()
示例12: del_from_keyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def del_from_keyring(keyring_id):
"""Delete an entry from the keyring."""
keyring = GnomeKeyring.get_default_keyring_sync()[1]
GnomeKeyring.item_delete_sync(keyring, keyring_id)
示例13: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def __init__(self):
self.keyring = GnomeKeyring.get_default_keyring_sync()[1]
示例14: __init__
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import get_default_keyring_sync [as 别名]
def __init__(self, name, server, protocol):
self._name = name
self._server = server
self._protocol = protocol
result, self._keyring = GnomeKeyring.get_default_keyring_sync()