Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
scollis committed Jan 23, 2014
1 parent d6b8353 commit 6914ff9
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions iastate_fetch_hrrr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@ def fetch_HRRR(forecast_time = 'f000', dimensionality = '3d', outdir = '/data/HR
last_dir = HRRR_url + all_times[-1]
print last_dir
filename = 'hrrr.' + dimensionality + '.' + all_times[-1] + forecast_time + '.grib2'
print filename
req = urllib2.urlopen(last_dir + '/' + filename)
exising_hrrr_files = os.listdir(outdir)
outfile = outdir + filename
if filename in exising_hrrr_files:
print('File exists, saving bandwidth')
else:
print('fetching')
state = 'working'
try:
req = urllib2.urlopen(last_dir + '/' + filename)
except:
outfile = 'null'
print('File not found, skipping')
state = 'dead'
if state == 'working':
outobj=open(outfile, 'wb')
outobj.write(req.read())
outobj.close()
except:
outfile = 'null'
print('File not found, skipping')
return outfile

if __name__ == '__main__':
Expand Down

0 comments on commit 6914ff9

Please sign in to comment.