def get_password(keyringid,identifier):
#This pops up the password prompt but is currently broken
#https://bugs.launchpad.net/ubuntu/+source/gnome-python-desktop/+bug/432882
#gnomekeyring.unlock_sync(keyringid, None)
for keyring in gnomekeyring.list_keyring_names_sync():
if(keyring == keyringid):
for id in gnomekeyring.list_item_ids_sync(keyring): item = gnomekeyring.item_get_info_sync(keyring, id) print(item.get_display_name()) if(item.get_display_name() == identifier): return item.get_secret()
Just as some background, I'm trying to use it with offlineimap, which allows the user to include python functions to retrieve username or password.
% egrep "(passeval|py)" ~/.offlineimaprc gnome.py "offlineimap" , "gmail. test.account" )
pythonfile = ~/.offlineimap.
remotepasseval = get_password(
% cat .offlineimap. gnome.py
#!/usr/bin/python
import sys '2.0')
import pygtk
pygtk.require(
import gtk # sets app name
import gnomekeyring
def get_password( keyringid, identifier) : /bugs.launchpad .net/ubuntu/ +source/ gnome-python- desktop/ +bug/432882 ng.unlock_ sync(keyringid, None) list_keyring_ names_sync( ): list_item_ ids_sync( keyring) :
item = gnomekeyring. item_get_ info_sync( keyring, id)
print( item.get_ display_ name())
if(item. get_display_ name() == identifier):
return item.get_secret()
#This pops up the password prompt but is currently broken
#https:/
#gnomekeyri
for keyring in gnomekeyring.
if(keyring == keyringid):
for id in gnomekeyring.
def main(): "offlineimap" ,"gmail. test.account" ) )
print( get_password(
if __name__ == "__main__":
main()