Skip to content
Snippets Groups Projects
Commit fe09935e authored by Martin Scarcia's avatar Martin Scarcia
Browse files

added load cfg command

parent 45eb1d2a
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ from collections import UserDict
import PyTango
import numpy as np
import importlib
import shutil
def fromPyTango2NumpyType(pytango_type):
""" Return the numpy type based on the PyTango type
......@@ -503,7 +504,37 @@ class Dynamic(PyTango.Device_4Impl):
self.myattrs = CaseLessDict()
self.read_functions = CaseLessDict()
self.write_functions = CaseLessDict()
#------------------------------------------------------------------
# Load config from remote location
#------------------------------------------------------------------
def LoadCfgFile(self, argin):
""" Load the file content as a String. Overwrite the existing cfg file.
:param argin: file content as String.
:type: PyTango.DevString
:return:
:rtype: PyTango.DevVoid
"""
# self.debug_stream("In LoadWorkingFile()")
if len(self.attr_WorkingFile_read) == 0:
self.error_stream('WorkingFile not defined, cannot procede.')
self.set_status('WorkingFile not defined, cannot procede.')
return
file_name = self.ConfiguratorScript
if os.path.isfile(file_name):
# File exists
backup_file = file_name + '.bak'
shutil.copyfile(file_name, backup_file)
try:
conf_file = open(file_name, 'w')
conf_file.write(argin)
self.debug_stream('Wrote file ' + file_name)
except Exception as ex:
self.error_stream('Unable to write file ' + file_name + ': ' + str(ex))
self.set_status('Unable to write file ' + self.ConfiguratorScript)
finally:
conf_file.close()
#==================================================================
#
# DynamicClass class utilities
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment