The following example demonstrates how the MacroServer environment is transferred to a local dictionary. The contents of the dictionary is printed. Notice that during the printout the keys are enclosed in '|' in order to detect any leading and trailing blank space.
The dictionary is changed and transferred back to the MacroServer.
#!/usr/bin/env python import os import PyTango from taurus.core.util.codecs import CodecFactory ms=PyTango.DeviceProxy("haso107d1:10000/p09/macroserver/haso107d1.01") # # Read environment # value = ms.Environment value = CodecFactory().getCodec('pickle').decode(value) dct = value[1]['new'] for key in list(dct.keys()): # # ScanHistory produces much output # if key == 'ScanHistory': continue print( "---- |%s| %s " % (key, dct[key])) # # Change environment. For ex. 'ScanDir' # dct['ScanDir'] = "/home/someUser/temp" new_value = dict(new=dct) new_value = CodecFactory().getCodec('pickle').encode((”, new_value)) # # update the macroserver # ms.write_attribute('Environment', new_value)