TelemacFile: crash when calling some methods when a file is not opened in readwrite mode
When using TelemacFile though Hermes to open a mesh file other than a SELAFIN file (for example MED or VTK), in write mode, a crash occurs when a property is called. This is because these properties call read methods that are not available when a file is opened in write-only mode.
As such, the following code will lead to a crash:
from data_manip.extraction.telemac_file import TelemacFile
f = TelemacFile("new_mesh.med", access="w")
f.ndim
This raises the following exception:
utils.exceptions.TelemacException: Hermes API error:
ERROR IN my_mesh.med: GET_MESH_DIMENSION_MED:MMHNAX
A similar crash happens when attempting to write a file opened in read mode, no matter the format:
from data_manip.extraction.telemac_file import TelemacFile
f = TelemacFile("geo_gouttedo.slf", access="r")
f.read()
f.write()
With the following exception:
utils.exceptions.TelemacException: Hermes API error:
ERROR IN geo_gouttedo.slf: SET_HEADER_SRF:WRITE:TITLE
To fix this, explicit exceptions must be thrown when an attempt is made to call these methods depending on the access mode.