简体   繁体   English

python keyring,无法设置密码

[英]python keyring, Cant set a password

I'm having a problem with python keyring after the installation. 我在安装后遇到了python keyring的问题。 here are my steps: 这是我的步骤:

$ python
>>> import keyring
>>> keyring.set_password('something','otherSomething','lotOfMoreSomethings')

and then throws this: 然后抛出这个:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/keyring/core.py", line 42, in set_password
   _keyring_backend.set_password(service_name, username, password)
File "/usr/local/lib/python2.6/dist-packages/keyring/backend.py", line 222, in set_password
   _, session = service_iface.OpenSession("plain", "")
File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 68, in __call__
   return self._proxy_method(*args, **keywords)
File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 140, in __call__
   **keywords)
File "/usr/lib/pymodules/python2.6/dbus/connection.py", line 630, in call_blocking
   message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod:
   Method "OpenSession" with signature "ss" on interface "org.freedesktop.Secret.Service" 
   doesn't exist

i have installed keyring from here using 我已经从这里安装了密钥环

easy_install keyring

Do i do anything wrong?? 我做错了什么? There are any solution?? 有什么解决方案??

Edit: 编辑:

Also i've installed python-keyring and python-keyring-gnome from repos and just import like 我还从repos安装了python-keyring和python-keyring-gnome,只是导入了

>>> import gnome_keyring

and works. 和工作。

If using gnomekeyring python package, you can use item_create_sync method to create a new password entry or replace existing password for a given key 如果使用gnomekeyring python包,您可以使用item_create_sync方法创建新密码条目或替换给定密钥的现有密码

#!/usr/bin/env python
import gnomekeyring

gnomekeyring.item_create_sync ("keyring-name", gnomekeyring.ITEM_GENERIC_SECRET, "key-display-name", {}, "password", True)

where item_create_sync method signature is 其中item_create_sync方法签名是

item_create_sync (string? keyring, ItemType type, string display_name, AttributeList attributes, string secret, bool update_if_exists)

I've been having a similar problem but my DBus Exception was on kwalletd (specifically /modules/kwalletd) even though I use Gnome. 我一直有类似的问题,但我的DBus异常是在kwalletd(特别是/ modules / kwalletd),即使我使用Gnome。

My work around was to create a local "keyringrc.cfg" file like so: 我的工作是创建一个本地“keyringrc.cfg”文件,如下所示:

[backend]
default-keyring=keyring.backends.Gnome.Keyring

See the Python keyring Package for determining where the Config file path is for your system. 请参阅Python密钥环包以确定系统的Config文件路径的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM