Skip to content

Instantly share code, notes, and snippets.

@tiagocoutinho
Last active June 26, 2020 09:45
Show Gist options
  • Save tiagocoutinho/066edf744b9f8f511bd4c45282281259 to your computer and use it in GitHub Desktop.
Save tiagocoutinho/066edf744b9f8f511bd4c45282281259 to your computer and use it in GitHub Desktop.
sardana macro runner helper
# ncd/sardana/macro/__main__.py
from .init import init_macro_module
init_macro_module(__name__)

Sardana macro runner helper

to run macros from the command line type:

$ (i)python -i -m ncd.sardana.macro

>>> from ncd.sardana.macro.my_macro import my_macro
# ncd/sardana/macro/init.py
MACRO_SERVER = None
def init_macro_module(name):
global MACRO_SERVER
if name == '__main__' and MACRO_SERVER is None:
from sardana.macroserver.macroserver import MacroServer
MACRO_SERVER = MacroServer('ms/test/1', name='test')
return MACRO_SERVER
# ncd/sardana/macro/my_macro.py
from .init import init_macro_module
init_macro_module(__name__)
from sardana.macroserver.macro import macro
@macro([['message', [['message_item', Type.String, None,
'message item to be reported']], None,
'message to be reported']])
def my_macro(self, message):
self.output(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment