Errors and debug print as comment
This commit is contained in:
parent
edcc593322
commit
78cbd3e90f
4 changed files with 9 additions and 9 deletions
|
@ -7,7 +7,7 @@ Homepage = "https://susurrando.com"
|
|||
|
||||
[project]
|
||||
name = "restic_exporter"
|
||||
version = "0.0.9"
|
||||
version = "0.0.10"
|
||||
description = "Export to node exporter the summary of a restic backup"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]
|
||||
|
|
|
@ -65,7 +65,7 @@ class restic_exporter:
|
|||
with open(json_file, 'r') as file_pointer:
|
||||
content = file_pointer.readlines()
|
||||
except Exception as error:
|
||||
self._log.error(f"Error reading file '{json_file}'. Check permissions. {error}")
|
||||
self._log.error(f"# Error reading file '{json_file}'. Check permissions. {error}")
|
||||
|
||||
self.summary = {}
|
||||
for line in content:
|
||||
|
@ -77,11 +77,11 @@ class restic_exporter:
|
|||
if 'snapshot_id' in line_data:
|
||||
self.labels["snapshot_id"] = line_data['snapshot_id']
|
||||
except json.decoder.JSONDecodeError as error:
|
||||
self._log.error(f"Error decoding line '{line}'. {error}")
|
||||
self._log.error(f"# Error decoding line '{line}'. {error}")
|
||||
file_stats = os.stat(json_file)
|
||||
self.summary['timestamp'] = round(file_stats.st_mtime * 1000)
|
||||
self._log.debug(f"Summary: {json.dumps(self.summary, indent=2)}")
|
||||
self._log.debug(f"Labels: {self.labels}")
|
||||
self._log.debug(f"# Summary: {json.dumps(self.summary, indent=2)}")
|
||||
self._log.debug(f"# Labels: {self.labels}")
|
||||
|
||||
def _read_extra_labels(self, extra_labels):
|
||||
labels_ls = {}
|
||||
|
@ -89,7 +89,7 @@ class restic_exporter:
|
|||
if '=' in pair:
|
||||
k, v=pair.split('=', 1)
|
||||
labels_ls[k] = v
|
||||
self._log.debug(f"Added extra label '{k}'='{v}'")
|
||||
self._log.debug(f"# Added extra label '{k}'='{v}'")
|
||||
return labels_ls
|
||||
|
||||
def _convert_labels(self, labels):
|
||||
|
@ -98,7 +98,7 @@ class restic_exporter:
|
|||
labels_ls.append(f"{key}=\"{labels[key]}\"")
|
||||
text_labels = ','.join(labels_ls)
|
||||
labels_string = "{" + text_labels + "}"
|
||||
self._log.debug(f"Labels: {labels_string}")
|
||||
self._log.debug(f"# Labels: {labels_string}")
|
||||
return labels_string
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = restic_exporter
|
||||
version = 0.0.9
|
||||
version = 0.0.10
|
||||
|
||||
[options]
|
||||
packages = restic_exporter
|
||||
|
|
2
setup.py
2
setup.py
|
@ -2,7 +2,7 @@ import setuptools
|
|||
setuptools.setup(
|
||||
scripts=['restic_exporter/restic_exporter.py'],
|
||||
author="Antonio J. Delgado",
|
||||
version='0.0.9',
|
||||
version='0.0.10',
|
||||
name='restic_exporter',
|
||||
author_email="",
|
||||
url="",
|
||||
|
|
Loading…
Reference in a new issue