mirror of
https://github.com/netinvent/npbackup.git
synced 2026-01-06 07:34:17 +08:00
Linter fixes
This commit is contained in:
parent
4bb12721a3
commit
58c71fb553
3 changed files with 11 additions and 6 deletions
|
|
@ -478,7 +478,9 @@ def restic_output_2_metrics(restic_result, output, labels_string=None):
|
|||
|
||||
metrics.append(
|
||||
'restic_backup_failure{{{},timestamp="{}"}} {}'.format(
|
||||
labels_string, int(datetime.now(timezone.utc).timestamp()), 1 if errors else 0
|
||||
labels_string,
|
||||
int(datetime.now(timezone.utc).timestamp()),
|
||||
1 if errors else 0,
|
||||
)
|
||||
)
|
||||
return errors, metrics
|
||||
|
|
@ -590,14 +592,16 @@ if __name__ == "__main__":
|
|||
logger.error("Output directory {} does not exist.".format(destination_dir))
|
||||
sys.exit(2)
|
||||
|
||||
labels_string = 'action="backup",backup_job="{}",instance="{}"'.format(instance, backup_job)
|
||||
labels_string = 'action="backup",backup_job="{}",instance="{}"'.format(
|
||||
instance, backup_job
|
||||
)
|
||||
if args.labels:
|
||||
labels_string += ",{}".format(args.labels)
|
||||
destination_file = os.path.join(destination_dir, output_filename)
|
||||
try:
|
||||
with open(log_file, "r", encoding="utf-8") as file_handle:
|
||||
errors, metrics = restic_output_2_metrics(
|
||||
True, output=file_handle.readlines(), labels=labels_string
|
||||
True, output=file_handle.readlines(), labels_string=labels_string
|
||||
)
|
||||
if errors:
|
||||
logger.error("Script finished with errors.")
|
||||
|
|
|
|||
|
|
@ -113,8 +113,9 @@ def test_npbackup_cli_wrong_config_path():
|
|||
__main__.main()
|
||||
except SystemExit:
|
||||
print(str(logs))
|
||||
assert "Config file npbackup-non-existent.conf cannot be read or does not exist" in str(
|
||||
logs
|
||||
assert (
|
||||
"Config file npbackup-non-existent.conf cannot be read or does not exist"
|
||||
in str(logs)
|
||||
), "There should be a critical error when config file is not given"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def test_restic_str_output_2_metrics():
|
|||
instance = "test"
|
||||
backup_job = "some_nas"
|
||||
labels_string = f'action="backup",backup_job="{backup_job}",instance="{instance}"'
|
||||
|
||||
|
||||
for version, output in restic_str_outputs.items():
|
||||
print(f"Testing V1 parser restic str output from version {version}")
|
||||
errors, prom_metrics = restic_output_2_metrics(True, output, labels_string)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue