Skip to content
Snippets Groups Projects
Commit d0f6fbf8 authored by Chris Smith's avatar Chris Smith
Browse files

Updated error handling in ioHDF.repack

Works in Spyder and allows catching of repack error
parent 0a5fef99
No related branches found
No related tags found
1 merge request!13Pyspm port suhas
...@@ -85,22 +85,27 @@ class ioHDF5(object): ...@@ -85,22 +85,27 @@ class ioHDF5(object):
''' '''
try: try:
repack_line = 'h5repack '+self.path+' '+tmpfile repack_line = 'h5repack '+self.path+' '+tmpfile
subprocess.call(repack_line, shell=True) subprocess.check_output(repack_line,
stderr=subprocess.STDOUT,
shell=True)
sleep(2) sleep(2)
except: except subprocess.CalledProcessError as err:
print('Could not repack hdf5 file') print('Could not repack hdf5 file')
raise StandardError(sys.stderr) raise Exception(err.output)
''' '''
Delete the original file and move the temporary file to the originals path Delete the original file and move the temporary file to the originals path
''' '''
# TODO Find way to get the real OS error that works in and out of Spyder
try: try:
os.remove(self.path) os.remove(self.path)
os.rename(tmpfile, self.path) os.rename(tmpfile, self.path)
except: except:
print('Could not copy repacked file to original path.') print('Could not copy repacked file to original path.')
raise StandardError(os.error) print('The original file is located {}'.format(self.path))
print('The repacked file is located {}'.format(tmpfile))
raise
''' '''
Open the repacked file Open the repacked file
''' '''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment