From 33310bc1c732d51ae7a4b3851fa4685e20a91180 Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Wed, 12 Apr 2023 10:03:56 +0200 Subject: [PATCH] Make sure runner creation failure is not fatal --- npbackup/__main__.py | 11 ++++------- npbackup/core/runner.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/npbackup/__main__.py b/npbackup/__main__.py index f501907..4381db7 100644 --- a/npbackup/__main__.py +++ b/npbackup/__main__.py @@ -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(): diff --git a/npbackup/core/runner.py b/npbackup/core/runner.py index efa4ecf..68573b0 100644 --- a/npbackup/core/runner.py +++ b/npbackup/core/runner.py @@ -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):