Add try except block to trigger errors for invalid group names.

This commit is contained in:
2025-02-06 16:07:45 +01:00
parent 2f72177410
commit b374de60f3

View File

@ -193,6 +193,7 @@ def create_hdf5_file_from_filesystem_path(path_to_input_directory: str,
if len(tmp_list) > offset+1:
group_name = '/'.join([tmp_list[i] for i in range(offset+1)])
try:
# Create group called "group_name". Hierarchy of nested groups can be implicitly defined by the forward slashes
if not group_name in h5file.keys():
h5file.create_group(group_name)
@ -204,6 +205,10 @@ def create_hdf5_file_from_filesystem_path(path_to_input_directory: str,
instFoldermsgStart = f'Starting data transfer from instFolder: {group_name}'
print(instFoldermsgStart)
except Exception as inst:
stdout = inst
logging.error('Failed to create group %s into HDF5: %s', group_name, inst)
for filenumber, filename in enumerate(filtered_filenames_list):
#file_ext = os.path.splitext(filename)[1]