Skip to content

Commit

Permalink
adding error handling for cnvstat
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewEichmann-NOAA committed Jun 15, 2023
1 parent 2d53c8f commit 71fccb0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ush/diag_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ def get_diag_stats():
zipfilename = diagfilename + '.gz'
outfilename = 'cnvstat.' + var + '.gdas.' + pdy + cyc + '.csv'

with tarfile.open(os.path.join(comout, tarfilename), "r") as tf:
tf.extract(member=zipfilename)
try:
with tarfile.open(os.path.join(comout, tarfilename), "r") as tf:
tf.extract(member=zipfilename)
except FileNotFoundError:
print('WARNING: file', os.path.join(comout, tarfilename),
'not found, this is expected in GDASApp ctests')
return
with gzip.open(zipfilename, 'rb') as f_in:
with open(diagfilename, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
Expand Down

0 comments on commit 71fccb0

Please sign in to comment.