- The MacroPath property, a list of strings, defines the search path of the MacroServer.
Python files stored in one of the directories
are loaded by the MacroServer.
- /home/pXXuser/sardanaMacros.
This directory is visible on one ExpPC only. The beamline user has rw-access.
- /gpfs/local/sardanaMacros.
This directory is visible to all ExpPCs of a beamline. The beamline user has rw access.
- /common/pXX/sardanaMacros.
This directory is DESY-wide visible. The beamline user has r-access.
The files can be edited via the core cluster using a regular DESY account.
- /bl_documents/sardanaMacros.
Mounted rw in the beamline space, no access from Maxwell.
- /usr/share/pyshared/sardana/sardana-macros/DESY_general.
This directory stores Macros common to all beamlines. The beamline
user has r-access.
In addition, /usr/lib/python2.7/dist-packages/sardana/macroserver and
/usr/lib/python2.7/dist-packages/sardana/macroserver/macros store Macros that come with Sardana.
- The PythonPath property, a list of strings, extends the search path for Python:
- /common/pXX/PythonPath.
This directory is DESY-wide visible. The beamline user has r-access.
The files can be edited via the core cluster using a regular DESY account.
- /gpfs/local/PythonPath.
This directory is visible to all ExpPCs of a beamline. The beamline user has rw access.
- /bl_documents/PythonPath.
This directory is visible to all ExpPCs of a beamline. The beamline user has rw access.
- /home/pXXuser/sardanaMacros/generalFunctions.
This directory is visible on one ExpPC only. The beamline user has rw-access.
This directory contains general_functions.py with the hooks, the check_condition function
and the general_on_stop function. These features can be enabled and disabled.
- A newly created Python script containing Macros is loaded into the MacroServer by restarting it or
by issuing addmaclib within Spock:
$ SardanaRestartMacroServer.py -x
p09/door/exp.01 [8]: %addmaclib hello_world
- Macro code that has been changed has to be reloaded by relmac or
relmaclib.
Lets's assume that the Macro hello_world is contained in the Python file
/home/pXXuser/sardanaMacros/funnyStuff.py and that this file is loaded into the
MacroServer. After funnyStuff.py has been edited the following
commands are equivalent:
p09/door/exp.01 [8]: %relmac hello_world
p09/door/exp.01 [9]: %relmaclib funnyStuff.py
Notice that both commands reload all Macros contained in funnyStuff.py.
Notice that also new Macros which have been added to funnyStuff.py are made available.
Notice that, if funnyStuff.py contains e.g. the statement import p99utils, the module
p99utils.py is not re-imported by relmac or relmaclib. After editing p99utils.py
the user has to restart the MacroServer or use the reload() function.
- The command SardanaMacroTester.py checks all Macros in
the MacroPath. It reports
- Python errors
- conflicting Macro library names
- conflicting class names
- Use pylint to check the syntax of Macro modules:
$ pylint -E fileName.py
The '-E' option displays errors only. Unfortunately Sardana macros do not
pass general syntax checks. Errors of the kind
E: 17,23:laser_scan: Instance of 'TypeNames' has no 'Moveable' member
E: 18,23:laser_scan: Instance of 'TypeNames' has no 'Float' member
cannot be avoided and have to be ignored. Still pylint -E is useful. If
you find other errors like
E: 26,29:laser_scan.run: Undefined variable 'A'
you have to fix them.
- Macros that have to be interrupted by Ctrl-C use checkPoint() to help the MacroServer to clean-up things.
See 6.1.1.
- If a Macro is interrupted by Ctrl-C, the on_stop function is invoked.
- Macros can be implemented as functions or as classes. Experience shows
that the class syntax seems to be more convenient.
- The command spock> prdef MacroName shows the Macro code.
- The command lsmac MacroName shows the library name with the path name. The argument
is used as a filter (regular expression syntax) to limit the output, e.g.
lsmac mv.*
, lsmax a.*scan
.