Make sure runner creation failure is not fatal

This commit is contained in:
Orsiris de Jong 2023-04-12 10:03:56 +02:00
parent 0e7e6214b9
commit 33310bc1c7
2 changed files with 13 additions and 14 deletions

View file

@ -403,13 +403,10 @@ This is free software, and you are welcome to redistribute it under certain cond
if args.dry_run:
dry_run = True
try:
npbackup_runner = NPBackupRunner(config_dict=config_dict)
npbackup_runner.dry_run = dry_run
npbackup_runner.verbose = _VERBOSE
logger.info("Backend: {}".format(npbackup_runner.backend_version))
except ValueError:
logger.critical("Cannot create backend")
npbackup_runner = NPBackupRunner(config_dict=config_dict)
npbackup_runner.dry_run = dry_run
npbackup_runner.verbose = _VERBOSE
logger.info("Backend: {}".format(npbackup_runner.backend_version))
if args.check:
if npbackup_runner.check_recent_backups():

View file

@ -119,20 +119,20 @@ class NPBackupRunner:
self._verbose = False
self._stdout = None
self.restic_runner = None
self._minimim_backup_age = None
self.minimum_backup_age = None
self._exec_time = None
self.is_ready = False
# Create an instance of restic wrapper
if not self.create_restic_runner():
raise ValueError("Cannot create backend runner")
self.create_restic_runner()
# Configure that instance
self.apply_config_to_restic_runner()
@property
def backend_version(self):
if self.restic_runner:
def backend_version(self) -> bool:
if self.is_ready:
return self.restic_runner.binary_version
return None
@property
def dry_run(self):
@ -173,8 +173,10 @@ class NPBackupRunner:
self.apply_config_to_restic_runner()
@property
def has_binary(self):
return True if self.restic_runner.binary else False
def has_binary(self) -> bool:
if self.is_ready:
return True if self.restic_runner.binary else False
return False
@property
def exec_time(self):