Beispiel #1
0
 def run(self, software_name=None):
     items = []
     try:
         import secretstorage
         import dbus
         import datetime
         for item in secretstorage.Collection(
                 dbus.SessionBus()).get_all_items():
             values = {
                 'created':
                 str(datetime.datetime.fromtimestamp(item.get_created())),
                 'modified':
                 str(datetime.datetime.fromtimestamp(item.get_modified())),
                 'content-type':
                 item.get_secret_content_type(),
                 'label':
                 item.get_label(),
                 'Password':
                 item.get_secret(),
             }
             for k, v in item.get_attributes().iteritems():
                 values[str(k)] = str(v)
             items.append(values)
         return items
     except Exception as e:
         print_debug('ERROR', 'libsecret: {0}'.format(e))
Beispiel #2
0
 def get_preferred_collection(self):
     """If self.preferred_collection contains a D-Bus path, the collection
     at that address is returned. Otherwise, the default collection is returned.
     """
     bus = secretstorage.dbus_init()
     try:
         if hasattr(self, 'preferred_collection'):
             collection = secretstorage.Collection(bus, self.preferred_collection)
         else:
             collection = secretstorage.get_default_collection(bus)
     except exceptions.SecretStorageException as e:
         raise InitError("Failed to create the collection: %s." % e)
     if collection.is_locked():
         collection.unlock()
         if collection.is_locked(): # User dismissed the prompt
             raise InitError("Failed to unlock the collection!")
     return collection