Finishing the Sardana configuration: /online_dir/SardanaConfig.py

The file /online_dir/SardanaConfig.py is executed at the end of the SardanaStartup.py script. This is an example:

#!/usr/bin/python
#
# /online_dir/SardanaConfig.py
#
import PyTango
import HasyUtils
import sys


print "\n--- executing %s \n" % __file__

#
# change the configuration of several attributes
#
devices = { "motor/omsvme58_d1/1": 
            { "Position": { "Label": "Ort1",  "Format": "%12g", "Unit": "mm"},
              "Offset": { "Label": "Aufsatz", "Format": "%11g", "Unit": "mm"},
              },
            "motor/omsvme58_d1/2": 
            { "Position": { "Label": "Ort2", "Format": "%12g", "Unit": "Degree"},
              "Offset": { "Label": "Aufsatz2", "Format": "%11g", "Unit": "Degree"},
              },
            }
                                    
for dev in devices.keys():
    print "device", dev
    try:
        proxy = PyTango.DeviceProxy( dev)
    except:
        print "The attribute configuration failed for %s" % dev
        continue
    for attr in devices[dev].keys():
        print " ",attr
        attrInfo = proxy.get_attribute_config( attr)
        for attrCfg in devices[dev][attr].keys():
            temp = "attrInfo.%s = \"%s\"" % (attrCfg.lower(), devices[dev][attr][attrCfg])
            print "  ",temp
            exec temp            
        proxy.set_attribute_config( attrInfo)
#
# Set some view options
#
HasyUtils.configMacroServer( 
    [ "setvo ShowDial False",
      "setvo ShowCtrlAxis True"])
#
# Set some environment variables. 'Cautious' means that variables
# are not overridden, if the exist already
#
HasyUtils.setEnvCautious( 
    {"JsonRecorder": "True", 
     "ScanDir": "/home/kracht/temp", 
     "ScanFile": "tst.fio"})

sys.exit( 0)

To overwrite the MacroPath property of the MacroServer, maybe during the development of new Macros, the following lines have to be added before sys.exit().

 

HasyUtils.putDeviceProperty( 'p17/macroserver/haspp17.01',
                             'MacroPath',
                             [
                                 '/usr/lib/python2.7/dist-packages/sardana/sardana-macros/DESY_general',
                                 '/common/p17/sardanaMacros',
                                 '/home/p17user/sardanaMacros',
                                 '/gpfs/local/sardanaMacros', 
                                 '/bl_documents/sardanaMacros'
                             ]
                         )

HasyUtils.restartServer( 'MacroServer/haspp17')



2019-11-13