summaryrefslogtreecommitdiffstats
path: root/glances/exports/glances_json/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'glances/exports/glances_json/__init__.py')
-rw-r--r--glances/exports/glances_json/__init__.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/glances/exports/glances_json/__init__.py b/glances/exports/glances_json/__init__.py
index 62a3c204..1a2aa6df 100644
--- a/glances/exports/glances_json/__init__.py
+++ b/glances/exports/glances_json/__init__.py
@@ -12,7 +12,7 @@ class Export(GlancesExport):
def __init__(self, config=None, args=None):
"""Init the JSON export IF."""
- super(Export, self).__init__(config=config, args=args)
+ super().__init__(config=config, args=args)
# JSON file name
self.json_filename = args.export_json_file
@@ -21,11 +21,11 @@ class Export(GlancesExport):
try:
self.json_file = open(self.json_filename, 'w')
self.json_file.close()
- except IOError as e:
- logger.critical("Cannot create the JSON file: {}".format(e))
+ except OSError as e:
+ logger.critical(f"Cannot create the JSON file: {e}")
sys.exit(2)
- logger.info("Exporting stats to file: {}".format(self.json_filename))
+ logger.info(f"Exporting stats to file: {self.json_filename}")
self.export_enable = True
@@ -34,7 +34,7 @@ class Export(GlancesExport):
def exit(self):
"""Close the JSON file."""
- logger.debug("Finalise export interface %s" % self.export_name)
+ logger.debug(f"Finalise export interface {self.export_name}")
self.json_file.close()
def export(self, name, columns, points):
@@ -44,11 +44,11 @@ class Export(GlancesExport):
if name == self.last_exported_list()[0] and self.buffer != {}:
# One whole loop has been completed
# Flush stats to file
- logger.debug("Exporting stats ({}) to JSON file ({})".format(listkeys(self.buffer), self.json_filename))
+ logger.debug(f"Exporting stats ({listkeys(self.buffer)}) to JSON file ({self.json_filename})")
# Export stats to JSON file
with open(self.json_filename, "w") as self.json_file:
- self.json_file.write("{}\n".format(json_dumps(self.buffer)))
+ self.json_file.write(f"{json_dumps(self.buffer)}\n")
# Reset buffer
self.buffer = {}