Created
March 16, 2009 03:33
-
-
Save segphault/79693 to your computer and use it in GitHub Desktop.
Fix the gnome keyring fallback support in Gwibber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
import gnomekeyring | |
except: | |
gnomekeyring = None | |
... | |
# Edited version of getitem/setitem in the config.py Account class | |
# This will probably fix the gnomekeyring fallback | |
def __getitem__(self, key): | |
if key.startswith("private:") and gnomekeyring: | |
try: | |
key = key.replace("private:", "") | |
return gnomekeyring.find_items_sync( | |
gnomekeyring.ITEM_GENERIC_SECRET, | |
{"id": "%s/%s/%s" % (self.path, self.id, key)})[0].secret | |
except gnomekeyring.NoMatchError: | |
return Wrapper.__getitem__(self, "%s/%s" % (self.id, key)) | |
else: | |
key = key.replace("private:", "") | |
return Wrapper.__getitem__(self, "%s/%s" % (self.id, key)) | |
def __setitem__(self, key, value): | |
if key.startswith("private:") and gnomekeyring: | |
key = key.replace("private:", "") | |
token = gnomekeyring.item_create_sync( | |
gnomekeyring.get_default_keyring_sync(), | |
gnomekeyring.ITEM_GENERIC_SECRET, "Gwibber preference: %s/%s" % (self.id, self.key), | |
{"id": "%s/%s/%s" % (self.path, self.id, key)}, value, True) | |
Wrapper.__setitem__(self, "%s/%s" % (self.id, key), ":KEYRING:%s" % token) | |
else: | |
key = key.replace("private:", "") | |
Wrapper.__setitem__(self, "%s/%s" % (self.id, key), value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment