本文整理汇总了Python中gi.repository.GnomeKeyring.delete_sync方法的典型用法代码示例。如果您正苦于以下问题:Python GnomeKeyring.delete_sync方法的具体用法?Python GnomeKeyring.delete_sync怎么用?Python GnomeKeyring.delete_sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GnomeKeyring
的用法示例。
在下文中一共展示了GnomeKeyring.delete_sync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_gnome_keyring
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import delete_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
示例2: before_all
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import delete_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')
示例3: tearDown
# 需要导入模块: from gi.repository import GnomeKeyring [as 别名]
# 或者: from gi.repository.GnomeKeyring import delete_sync [as 别名]
def tearDown(self):
'''Ensure that we do no leave test keyring behind.'''
GnomeKeyring.delete_sync(TEST_KEYRING)