h5serv
h5serv copied to clipboard
Catch IOError and exit gracefully for h5tojson tool.
I tested it with an invalid HDF5 file and got the following error.
python h5tojson.py -d /mnt/ftp/pub/outgoing/NASAHDF/AGNS1km.v003.68.-064.0010.h5.2.jpg > /Users/hyoklee/src/hpd/AGNS1km.v003.68.-064.0010.h5.2.jpg.json
Traceback (most recent call last):
File "h5tojson.py", line 236, in <module>
main()
File "h5tojson.py", line 231, in main
with Hdf5db(filename, dbFilePath=dbFilename, readonly=True, app_logger=log) as db:
File "../server/hdf5db.py", line 108, in __init__
self.f = h5py.File(filePath, mode)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_hl/files.py", line 231, in __init__
fid = make_fid(name, mode, userblock_size, fapl)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_hl/files.py", line 78, in make_fid
fid = h5f.open(name, h5f.ACC_RDONLY, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/_objects.c:2405)
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/_objects.c:2362)
File "h5py/h5f.pyx", line 72, in h5py.h5f.open (/Users/travis/build/MacPython/h5py-wheels/h5py/h5py/h5f.c:1738)
IOError: Unable to open file (File signature not found)