--- a/backup.py Sat Jan 20 23:50:36 2018 +0000 +++ b/backup.py Sun Jan 21 00:58:06 2018 +0000 @@ -72,15 +72,20 @@ 'Prune parameters', self.loc, default=[]) - keychain_account=config.check_string(cfg, 'keychain_account', - 'Keychain account', self.loc, - default='') + self.__keychain_account=config.check_string(cfg, 'keychain_account', + 'Keychain account', self.loc, + default='') + + if config.settings['__extract_passphrases_at_startup']: + self.extract_passphrase() - if keychain_account and keychain_account!='': - pw=keyring.get_password("borg-backup", keychain_account) - self.__password=pw + def extract_passphrase(self): + acc=self.__keychain_account + if acc and acc!='': + pw=keyring.get_password("borg-backup", acc) + self.__passphrase=pw else: - self.__password=None + self.__passphrase=None def __init__(self, identifier, cfg): self.identifier=identifier @@ -97,7 +102,7 @@ self.timer=None self.scheduled_operation=None self.lock=Lock() - self.status_update_callback=None + self.__status_update_callback=None def is_running(self): with self.lock: @@ -123,7 +128,7 @@ logging.debug(str(status)) t=status['type'] - errors_this_message=False + errors_this_message=None callback=None if t=='progress_percent': @@ -162,19 +167,15 @@ lvl=translate_loglevel(status['levelname']) logging.log(lvl, status['name'] + ': ' + status['message']) if lvl>=logging.WARNING: - errors_this_message=True - elif t=='exception': - errors_this_message=True - elif t=='unparsed_error': - errors_this_message=True - - if errors_this_message: - with self.lock: - self.current_operation['errors']=True - status, callback=self.__status_unlocked() + errors_this_message=status + with self.lock: + self.current_operation['errors']=True + status, callback=self.__status_unlocked() + else: + logging.debug('Unrecognised log entry %s' % str(status)) if callback: - callback(self, status) + callback(self, status, errors=errors_this_message) logging.debug('Waiting for borg subprocess to terminate in log thread') @@ -221,8 +222,10 @@ callback(self, status) def __do_launch(self, queue, op, archive_or_repository, *args): + self.extract_passphrase() + inst=BorgInstance(op['operation'], archive_or_repository, *args) - inst.launch(password=self.__password) + inst.launch(passphrase=self.__passphrase) t_log=Thread(target=self.__log_listener) t_log.daemon=True @@ -378,17 +381,13 @@ with self.lock: return self.__schedule_unlocked() - def set_status_update_callback(self, callback): - with self.lock: - self.status_update_callback=callback - def status(self): with self.lock: res=self.__status_unlocked() return res[0] def __status_unlocked(self): - callback=self.status_update_callback + callback=self.__status_update_callback if self.current_operation: status=self.current_operation status['type']='current' @@ -409,5 +408,8 @@ return status, callback + def set_status_update_callback(self, callback): + with self.lock: + self.__status_update_callback=callback