Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Fix Spec user custom data #1690

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/sardana/macroserver/recorders/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from sardana.macroserver.scan.recorder import (BaseFileRecorder,
BaseNAPI_FileRecorder,
SaveModes)
from sardana.sardanacustomsettings import SPEC_CUSTOM_DATA_FORMAT
from taurus.core.util.containers import chunks


Expand Down Expand Up @@ -496,7 +497,7 @@ def _endRecordList(self, recordlist):
self.fd.flush()
self.fd.close()

def _addCustomData(self, value, name, **kwargs):
def _addCustomData(self, value, name, spec_custom_fmt=None, **kwargs):
'''
The custom data will be added as a comment line in the form::

Expand Down Expand Up @@ -526,7 +527,13 @@ def _addCustomData(self, value, name, **kwargs):
self.info(
'Custom data "%s" will not be stored in SPEC file. Reason: cannot open file', name)
return
self.fd.write(str('#C %s : %s\n' % (name, v)))
if spec_custom_fmt is None:
spec_custom_fmt = SPEC_CUSTOM_DATA_FORMAT

if '\n' not in spec_custom_fmt:
spec_custom_fmt += '\n'

self.fd.write(spec_custom_fmt.format(value=v, name=name))
self.fd.flush()
if fileWasClosed:
self.fd.close() # leave the file descriptor as found
Expand Down
6 changes: 6 additions & 0 deletions src/sardana/sardanacustomsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,9 @@
#: places are not called in simple mv-based macros but only in scan-based
#: macros
PRE_POST_MOVE_HOOK_IN_MV = True


#: Default SPEC custom data format.
#:
#: For backward compatibility change to: '#C {name} : {value}\n'
SPEC_CUSTOM_DATA_FORMAT = '#UVAR {name} {value}\n'