From a58d9dd1721fd0740720c80e2c587b9dfb3a6be3 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 30 Aug 2024 11:55:50 +0000 Subject: try to trap errors --- scan.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scan.py b/scan.py index b53de68..b55526c 100755 --- a/scan.py +++ b/scan.py @@ -25,9 +25,14 @@ class Prom: for field in fields: output = output + "# HELP therm_{0} {0}\n# TYPE therm_{0} gauge\n".format(field) for mac in self.collected: - output = output + "therm_{0}{{mac=\"{1}\"}} {2:f}\n".format( - field, mac, self.collected[mac][field][0] - ) + try: + output = output + "therm_{0}{{mac=\"{1}\"}} {2:f}\n".format( + field, mac, self.collected[mac][field][0] + ) + except E: + output = output + "# therm_{0}{{mac=\"{1}\"}} {2}\n".format( + field, mac, E + ) headers = HttpHeaders() headers.set('Content-type', 'text/plain; version=0.0.4; charset=utf-8; escaping=values') -- cgit v1.2.3