sardana-org / sardana

Moved to GitLab: https://gitlab.com/sardana-org/sardana
39 stars 52 forks source link

h5 file cannot be saved if already existing if adding custom data #514

Open mrosanes opened 7 years ago

mrosanes commented 7 years ago

If an .h5 scan file (defined in the sardana environment variable ScanFile) is already existing, and we execute the exemplary macro 'ascan_with_addcustomdata', that should overwrite the h5 scan file and create a new one. This is not the case; the new scan file cannot be created, and an error is displayed in the spock command line:

An error occurred while running Macro 'ascan_with_addcustomdata(mot41, 2.0, 10.0, 10, 0.1) -> 8ae2be1a-73a8-11e7-bff5-00163e482412':
NXscanH5_FileRecorder can not process custom data: unable to create link (Links: Unable to initialize object)

Using the debug mode in spock (for more information about the bug):

%ascan_with_addcustomdata mot41 2 10 10 0.1
[START] runMacro Macro 'ascan_with_addcustomdata(mot41, 2.0, 10.0, 10, 0.1) -> 8ae2be1a-73a8-11e7-bff5-00163e482412'
Custom data: dummyChar1 : Hello world1
Sending exception event
[ENDEX] (MacroServerException) runMacro ascan_with_addcustomdata
Traceback (most recent call last):
  File "/home/mrosanes/PycharmProjects/sardana/src/sardana/macroserver/msmacromanager.py", line 1277, in runMacro
    for step in macro_obj.exec_():
  File "/home/mrosanes/PycharmProjects/sardana/src/sardana/macroserver/macro.py", line 2276, in exec_
    for i in it:
  File "/home/mrosanes/PycharmProjects/sardana/src/sardana/macroserver/macros/examples/scans.py", line 612, in run
    nxpath='/custom_entry:NXentry/customdata:NXcollection')
  File "/home/mrosanes/PycharmProjects/sardana/src/sardana/macroserver/scan/recorder/datarecorder.py", line 85, in addCustomData
    recorder.addCustomData(value, name, **kwargs)
  File "/home/mrosanes/PycharmProjects/sardana/src/sardana/macroserver/scan/recorder/datarecorder.py", line 155, in addCustomData
    (self.__class__.__name__, e))
RuntimeError: NXscanH5_FileRecorder can not process custom data: unable to create link (Links: Unable to initialize object)

An error occurred while running Macro 'ascan_with_addcustomdata(mot41, 2.0, 10.0, 10, 0.1) -> 8ae2be1a-73a8-11e7-bff5-00163e482412':
NXscanH5_FileRecorder can not process custom data: unable to create link (Links: Unable to initialize object)
Job ended (stopped=False, aborted=False)
mrosanes commented 7 years ago

If removing the scan file, and relaunching the macro 'ascan_with_addcustomdata', then the h5 file is created correctly.