Exemplo n.º 1
0
 def is_unlocked(self):
     try:
         collection = secretstorage.get_default_collection(self.connection)
         return not collection.is_locked()
     except secretstorage.exceptions.SecretServiceNotAvailableException:
         logger.debug('SecretStorage is closed.')
         return False
Exemplo n.º 2
0
def call_ipconfig_getpacket(bsd_device):
    cmd = ['ipconfig', 'getpacket', bsd_device]
    try:
        return subprocess.check_output(cmd)
    except subprocess.CalledProcessError:
        logger.debug("Command %s failed", ' '.join(cmd))
        return b''
Exemplo n.º 3
0
 def is_unlocked(self):
     try:
         collection = secretstorage.get_default_collection(self.connection)
         if collection.is_locked():  # Prompt for unlock
             collection.unlock()
         return not collection.is_locked()  # In case of denial
     except secretstorage.exceptions.SecretServiceNotAvailableException:
         logger.debug('SecretStorage is closed.')
         return False
Exemplo n.º 4
0
 def get_password(self, service, repo_url):
     if self.is_unlocked:
         asyncio.set_event_loop(asyncio.new_event_loop())
         collection = secretstorage.get_default_collection(self.connection)
         attributes = {
             'application': 'Vorta',
             'service': service,
             'repo_url': repo_url
         }
         items = list(collection.search_items(attributes))
         logger.debug('Found %i passwords matching repo URL.', len(items))
         if len(items) > 0:
             return items[0].get_secret().decode("utf-8")
     return None
Exemplo n.º 5
0
def call_networksetup_listallhardwareports():
    cmd = ['networksetup', '-listallhardwareports']
    try:
        return subprocess.check_output(cmd)
    except subprocess.CalledProcessError:
        logger.debug("Command %s failed", ' '.join(cmd))