Skip to content

Commit

Permalink
Catch non-netcdf files in database check
Browse files Browse the repository at this point in the history
Some non-netcdf format files were found in the windfield folder and were attempted to be read when creating the hazard database. Now captures a general exception raised by netCDF4-python when trying to load a file that isn't netcdf.
  • Loading branch information
wcarthur committed Dec 21, 2015
1 parent ec1c68b commit 0d4c844
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion database/__init__.py
Expand Up @@ -138,7 +138,11 @@ def windfieldAttributes(ncfile):
global attributes in the netCDF file.
"""
ncobj = Dataset(ncfile, 'r')
try:
ncobj = Dataset(ncfile, 'r')
except Exception as err:
log.exception("Cannot open file: {0}: {1}".format(ncfile, err.args[0]))
raise
trackfile = getattr(ncobj, 'track_file')
trackfiledate = getattr(ncobj, 'track_file_date')
trackfiledate = datetime.strptime(trackfiledate, '%Y-%m-%d %H:%M:%S')
Expand Down

0 comments on commit 0d4c844

Please sign in to comment.