From 035803fbe2a7290fe2022716444c0853747268a2 Mon Sep 17 00:00:00 2001 From: Jose Gracia Date: Wed, 22 Nov 2023 10:52:49 +0100 Subject: [PATCH] Error handling for jobid without data --- monitoring/db/scripts/get_detailed_power.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/monitoring/db/scripts/get_detailed_power.py b/monitoring/db/scripts/get_detailed_power.py index 0a735e3..55a606e 100644 --- a/monitoring/db/scripts/get_detailed_power.py +++ b/monitoring/db/scripts/get_detailed_power.py @@ -57,7 +57,9 @@ class Power: @classmethod def from_db(cls, db, jobid, interval): all_list = db.db_to_list(jobid, interval) - + if not all_list: + raise RuntimeError + return Power.from_list(all_list) @@ -190,7 +192,12 @@ class App: def run_all(self): for jobid in self.config.jobid: - power = Power.from_db(self.db, jobid, self.config.interval) + try: + power = Power.from_db(self.db, jobid, self.config.interval) + except RuntimeError: + print('No data found for job ID "{}"'.format(jobid)) + continue + fn = power.to_file(jobid) if fn: print('Created file {fn}'.format(fn=fn))