def load_token(self): """ Check if auth key has been saved. :raises: ``KeyringLocked`` if the system keyring cannot be accessed. """ logger.debug("Using keyring: %s" % keyring.get_keyring()) try: if self.account_id == "": self.access_token = None else: self.access_token = keyring.get_password("Maestral", self.account_id) return self.access_token except KeyringLocked: info = "Please make sure that your keyring is unlocked and restart Maestral." raise KeyringLocked(info)
def _is_linked(conf): """ Checks if auth key has been saved. :raises: ``KeyringLocked`` if the system keyring cannot be accessed. """ account_id = conf.get("account", "account_id") try: if account_id == "": access_token = None else: access_token = keyring.get_password("Maestral", account_id) return access_token except KeyringLocked: info = "Please make sure that your keyring is unlocked and restart Maestral." raise KeyringLocked(info)
def load_token(self): """ Load auth token from system keyring. :returns: Auth token. :rtype: str :raises: ``KeyringLocked`` if the system keyring cannot be accessed. """ logger.debug(f'Using keyring: {self.keyring}') try: if self.account_id == '': self.access_token = None else: self.access_token = self.keyring.get_password( 'Maestral', self.account_id) return self.access_token except KeyringLocked: info = 'Please make sure that your keyring is unlocked and restart Maestral.' raise KeyringLocked(info)
def pending_link(config_name): """ Checks if auth key has been saved. This can be used by Maestral front ends to check if we are linked before starting a daemon. :param str config_name: The config to check. :returns: ``True`` or ``False``. :rtype: bool :raises: ``KeyringLocked`` if the system keyring cannot be accessed. """ set_keyring_backend() conf = MaestralConfig(config_name) account_id = conf.get('account', 'account_id') try: if account_id == '': access_token = None else: access_token = keyring.get_password('Maestral', account_id) return access_token is None except KeyringLocked: info = 'Please make sure that your keyring is unlocked and restart Maestral.' raise KeyringLocked(info)