Error handling for jobid without data
This commit is contained in:
parent
ee106619ea
commit
035803fbe2
1 changed files with 9 additions and 2 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue