nxsconfigserver 2.20.0__py3-none-any.whl → 2.21.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nxsconfigserver/Merger.py CHANGED
@@ -184,7 +184,7 @@ class Merger(object):
184
184
  res += ":" + name
185
185
  return res
186
186
 
187
- def __areMergeable(self, elem1, elem2, ancestors):
187
+ def __areMergeable(self, elem1, elem2, ancestors, node):
188
188
  """ checks if two elements are mergeable
189
189
 
190
190
  :param elem1: first element
@@ -216,10 +216,19 @@ class Merger(object):
216
216
  if tags:
217
217
  status = False
218
218
  if tagName in self.singles or (name1 and name1 == name2):
219
- raise IncompatibleNodeError(
220
- "Incompatible element attributes %s: %s"
221
- % (str(self.__getAncestors(elem1, ancestors)), str(tags)),
222
- [elem1, elem2])
219
+ if not self.skip:
220
+ if tags and tags[0] == ('TANGO', 'CLIENT'):
221
+ node.remove(elem2)
222
+ elif tags and tags[0] == ('CLIENT', 'TANGO'):
223
+ node.remove(elem1)
224
+ else:
225
+ raise IncompatibleNodeError(
226
+ "Incompatible element attributes %s: %s %s"
227
+ % (str(self.__getAncestors(elem1, ancestors)),
228
+ str(node.get("name")), str(tags)),
229
+ [elem1, elem2])
230
+ else:
231
+ status = False
223
232
 
224
233
  if tagName in self.uniqueText:
225
234
  text1 = unicode(self.__getText(elem1)).strip()
@@ -330,6 +339,9 @@ class Merger(object):
330
339
 
331
340
  children = list(node)
332
341
  c1 = 0
342
+ if unicode(node.tag) in self.switchable and self.switchdatasources:
343
+ # print("NODE", node.tag, node.get("name"))
344
+ self.__switch(node)
333
345
  while c1 < len(children):
334
346
  child1 = children[c1]
335
347
  c2 = c1 + 1
@@ -338,7 +350,7 @@ class Merger(object):
338
350
  if child1 != child2:
339
351
  if self.__areMergeable(
340
352
  child1, child2,
341
- ancestors):
353
+ ancestors, node):
342
354
  self.__mergeNodes(child1, child2, node)
343
355
  children.pop(c2)
344
356
  c2 -= 1
@@ -359,8 +371,9 @@ class Merger(object):
359
371
 
360
372
  self.__mergeChildren(child, newancestors, entrynode,
361
373
  datanode, linknode)
362
- if cName in self.switchable and self.switchdatasources:
363
- self.__switch(child)
374
+ # if cName in self.switchable and self.switchdatasources:
375
+ # print("CHILD", child.tag, child.get("name"))
376
+ # self.__switch(child)
364
377
  if cName in self.linkable and self.linkdatasources:
365
378
  datanode = self.__addlink(
366
379
  child, newancestors, entrynode, datanode,
@@ -431,7 +444,8 @@ class Merger(object):
431
444
  :type node: :obj:`xml.etree.ElementTree.Element`
432
445
  """
433
446
  if node is not None:
434
- stnode = None
447
+ stnodes = []
448
+ modes = []
435
449
  mode = None
436
450
  dsname = None
437
451
  dsnode = None
@@ -456,13 +470,18 @@ class Merger(object):
456
470
  elif cName == 'strategy':
457
471
  mode = child.get("mode")
458
472
  if mode in self.modesToSwitch.keys():
459
- stnode = child
460
- else:
461
- break
462
- if stnode is not None and dsnode is not None:
463
- break
464
- if stnode is not None and dsnode is not None:
465
- stnode.attrib["mode"] = self.modesToSwitch[mode]
473
+ stnodes.append(child)
474
+ modes.append(mode)
475
+ # else:
476
+ # break
477
+ # if stnode not None and dsnode is not None:
478
+ # break
479
+ if stnodes and dsnode is not None:
480
+ for si, stn in enumerate(stnodes):
481
+ mode = modes[si]
482
+ if mode in self.modesToSwitch.keys():
483
+ stn.attrib["mode"] = self.modesToSwitch[mode]
484
+ # print("SWITCH", node.get("name"), dsname, dsnode)
466
485
 
467
486
  def __canfail(self, node):
468
487
  """ switch the given node to canfail mode
@@ -135,17 +135,17 @@ class NXSConfigServer(tango.LatestDeviceImpl):
135
135
  return False
136
136
  return True
137
137
 
138
- def read_MergedXML(self, attr):
139
- """ Read MergedXML attribute
138
+ def read_XMLCache(self, attr):
139
+ """ Read XMLCache attribute
140
140
 
141
141
  :param attr: xml string attribute
142
142
  :type attr: :class:`tango.Attribute`
143
143
  """
144
- self.debug_stream("In read_MergedXML()")
145
- attr.set_value(self.xmlc.mergedxml)
144
+ self.debug_stream("In read_XMLCache()")
145
+ attr.set_value(self.xmlc.xmlcache)
146
146
 
147
- def is_MergedXML_allowed(self, _):
148
- """ MergedXML attribute State Machine
147
+ def is_XMLCache_allowed(self, _):
148
+ """ XMLCache attribute State Machine
149
149
 
150
150
  :returns: True if the operation allowed
151
151
  :rtype: :obj:`bool`
@@ -785,7 +785,7 @@ class NXSConfigServer(tango.LatestDeviceImpl):
785
785
 
786
786
  :brief: Creates the NDTS configuration script from the
787
787
  given components. The result is strored in XMLString
788
- and MergedXML
788
+ and XMLCache
789
789
 
790
790
  :param argin: DevVarStringArray list of component names
791
791
  :type argin: :obj:`list` <:obj:`str`>
@@ -810,6 +810,36 @@ class NXSConfigServer(tango.LatestDeviceImpl):
810
810
  return False
811
811
  return True
812
812
 
813
+ def CreateCache(self, argin):
814
+ """ CreateCache command
815
+
816
+ :brief: Creates the NDTS cache script from the
817
+ given components. The result is strored in XMLString
818
+ and XMLCache
819
+
820
+ :param argin: DevVarStringArray list of component names
821
+ :type argin: :obj:`list` <:obj:`str`>
822
+ """
823
+ self.debug_stream("In CreateCache()")
824
+ try:
825
+ self.set_state(tango.DevState.RUNNING)
826
+ self.xmlc.createCache(argin)
827
+ self.set_state(tango.DevState.OPEN)
828
+ finally:
829
+ if self.get_state() == tango.DevState.RUNNING:
830
+ self.set_state(tango.DevState.OPEN)
831
+
832
+ def is_CreateCache_allowed(self):
833
+ """ CreateCache command State Machine
834
+
835
+ :returns: True if the operation allowed
836
+ :rtype: :obj:`bool`
837
+ """
838
+ if self.get_state() in [tango.DevState.ON,
839
+ tango.DevState.RUNNING]:
840
+ return False
841
+ return True
842
+
813
843
  def DeleteComponent(self, argin):
814
844
  """ DeleteComponent command
815
845
 
@@ -1276,6 +1306,9 @@ class NXSConfigServerClass(tango.DeviceClass):
1276
1306
  'CreateConfiguration':
1277
1307
  [[tango.DevVarStringArray, "list of component names"],
1278
1308
  [tango.DevVoid, ""]],
1309
+ 'CreateCache':
1310
+ [[tango.DevVarStringArray, "list of component names"],
1311
+ [tango.DevVoid, ""]],
1279
1312
  'DeleteComponent':
1280
1313
  [[tango.DevString, "component name"],
1281
1314
  [tango.DevVoid, ""]],
@@ -1337,7 +1370,7 @@ class NXSConfigServerClass(tango.DeviceClass):
1337
1370
  "it contains the resulting XML configuration.",
1338
1371
  'Display level': tango.DispLevel.EXPERT,
1339
1372
  }],
1340
- 'MergedXML':
1373
+ 'XMLCache':
1341
1374
  [[tango.DevString,
1342
1375
  tango.SCALAR,
1343
1376
  tango.READ],
@@ -20,4 +20,4 @@
20
20
  """ release version module """
21
21
 
22
22
  #: version number
23
- __version__ = "2.20.0"
23
+ __version__ = "2.21.2"
@@ -87,7 +87,7 @@ class XMLConfigurator(object):
87
87
  #: (:obj:`str`) XML config string
88
88
  self.xmlstring = ""
89
89
  #: (:obj:`str`) Merged coponents in XML string without variables
90
- self.mergedxml = ""
90
+ self.xmlcache = ""
91
91
  #: (:obj:`str`) component selection
92
92
  self.selection = "{}"
93
93
  #: (:obj:`str`) JSON string with arguments to connect to database
@@ -831,9 +831,12 @@ class XMLConfigurator(object):
831
831
  name = subc.strip() if subc else ""
832
832
  if name:
833
833
  if tag and name not in keys:
834
- raise NonregisteredDBRecordError(
835
- "The %s %s of %s not registered in the DataBase" % (
836
- tag if tag else "variable", name, component))
834
+ if not onlyexisting:
835
+ raise NonregisteredDBRecordError(
836
+ "The %s %s of %s not registered in the "
837
+ "DataBase" % (
838
+ tag if tag else "variable",
839
+ name, component))
837
840
  try:
838
841
  xmlds = funValue([name], defsubc)
839
842
  except Exception:
@@ -842,7 +845,7 @@ class XMLConfigurator(object):
842
845
  raise NonregisteredDBRecordError(
843
846
  "The %s %s of %s not registered" % (
844
847
  tag if tag else "variable", name, component))
845
- if tag:
848
+ if tag and xmlds:
846
849
  if sys.version_info > (3,):
847
850
  root = et.fromstring(
848
851
  bytes(xmlds[0], "UTF-8"),
@@ -908,10 +911,12 @@ class XMLConfigurator(object):
908
911
  component, self.__varLabel,
909
912
  list(self.__parameters.keys()), self.__getVariable)
910
913
 
911
- def __attachComponents(self, component):
914
+ def __attachComponents(self, component, onlyexisting=False):
912
915
  """ attaches variables to component
913
916
 
914
917
  :param component: given component
918
+ :param onlyexisting: attachElement only if exists
919
+ :type onlyexisting: :obj:`bool`
915
920
  :type component: :obj:`str`
916
921
  :returns: component with attached variables
917
922
  :rtype: :obj:`str`
@@ -919,13 +924,16 @@ class XMLConfigurator(object):
919
924
  if not component:
920
925
  return
921
926
  return self.__attachElements(
922
- component, self.__cpLabel, [], lambda x, y: [""])
927
+ component, self.__cpLabel, [], lambda x, y: [""],
928
+ onlyexisting=onlyexisting)
923
929
 
924
- def __attachDataSources(self, component):
930
+ def __attachDataSources(self, component, onlyexisting=False):
925
931
  """ attaches datasources to component
926
932
 
927
933
  :param component: given component
928
934
  :type component: :obj:`str`
935
+ :param onlyexisting: attachElement only if exists
936
+ :type onlyexisting: :obj:`bool`
929
937
  :returns: component with attached datasources
930
938
  :rtype: :obj:`str`
931
939
  """
@@ -934,7 +942,7 @@ class XMLConfigurator(object):
934
942
  return self.__attachElements(
935
943
  component, self.__dsLabel,
936
944
  self.availableDataSources(), self.dataSources,
937
- "datasource")
945
+ "datasource", onlyexisting=onlyexisting)
938
946
 
939
947
  def merge(self, names):
940
948
  """ merges the give components
@@ -963,24 +971,35 @@ class XMLConfigurator(object):
963
971
  cpvars[str(key)] = str(value)
964
972
  return cpvars
965
973
 
966
- def __mergeVars(self, names, withVariables=False):
974
+ def __mergeVars(self, names, withVariables=False, onlyCache=False):
967
975
  """ merges the give components
968
976
 
969
977
  :param names: list of component names
970
978
  :type names: :obj:`list` <:obj:`str`>
971
979
  :param withVariables: if true variables will be substituted
972
980
  :param withVariables: :obj:`bool`
981
+ :param onlyCache: if true create only cache
982
+ :param onlyCache: :obj:`bool`
973
983
  :returns: merged components
974
984
  :rtype: :obj:`str`
975
985
  """
976
986
  xml = ""
977
987
  if self.__mydb:
978
- allnames = self.dependentComponents(
979
- list(set(self.__mydb.mandatory() + names)))
988
+ cached = [nm for nm in names if nm.startswith("__configuration_")]
989
+ if cached:
990
+ allnames = self.dependentComponents(list(set(names)))
991
+ else:
992
+ allnames = self.dependentComponents(
993
+ list(set(self.__mydb.mandatory() + names)))
980
994
  comps = self.__mydb.components(list(set(allnames)))
981
995
  xml = self.__merge(comps, skip=withVariables)
982
996
  if withVariables:
983
- self.mergedxml = xml or ""
997
+ xml = self.__attachDataSources(
998
+ self.__attachComponents(
999
+ xml, onlyexisting=True), onlyexisting=True)
1000
+ self.xmlcache = xml or ""
1001
+ if onlyCache:
1002
+ return self.xmlcache
984
1003
  if xml is not None:
985
1004
  comps = [xml]
986
1005
  cpvars = self.__variableComponentValues(comps)
@@ -998,11 +1017,12 @@ class XMLConfigurator(object):
998
1017
  :rtype: :obj:`str`
999
1018
  """
1000
1019
  mgr = Merger()
1001
- mgr.switchdatasources = json.loads(self.stepdatasources)
1002
- mgr.linkdatasources = json.loads(self.linkdatasources)
1003
- mgr.extralinkdatasources = json.loads(self.extralinkdatasources)
1004
- mgr.canfaildatasources = json.loads(self.canfaildatasources)
1005
- mgr.extralinkpath = self.__splitExtraPath(self.extraLinkPath)
1020
+ if not skip:
1021
+ mgr.switchdatasources = json.loads(self.stepdatasources)
1022
+ mgr.linkdatasources = json.loads(self.linkdatasources)
1023
+ mgr.extralinkdatasources = json.loads(self.extralinkdatasources)
1024
+ mgr.canfaildatasources = json.loads(self.canfaildatasources)
1025
+ mgr.extralinkpath = self.__splitExtraPath(self.extraLinkPath)
1006
1026
  mgr.skip = skip
1007
1027
  mgr.collect(xmls)
1008
1028
  mgr.merge()
@@ -1035,6 +1055,16 @@ class XMLConfigurator(object):
1035
1055
  epath.append([nd[0], "NX" + nd[0]])
1036
1056
  return epath
1037
1057
 
1058
+ def createCache(self, names):
1059
+ """ creates the final configuration string in the xmlstring attribute
1060
+
1061
+ :param names: list of component names
1062
+ :type names: :obj:`list` <:obj:`str`>
1063
+ """
1064
+ self.__mergeVars(names, withVariables=True, onlyCache=True)
1065
+ self._streams.info("XMLConfigurator::createConfiguration() "
1066
+ "- Create configuration")
1067
+
1038
1068
  def createConfiguration(self, names):
1039
1069
  """ creates the final configuration string in the xmlstring attribute
1040
1070
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nxsconfigserver
3
- Version: 2.20.0
3
+ Version: 2.21.2
4
4
  Summary: Configuration Server for Nexus Data Writer
5
5
  Home-page: http://github.com/jkotan/nexdatas/nxsconfigserver
6
6
  Author: Jan Kotanski, Eugen Wintersberger , Halil Pasic
@@ -0,0 +1,14 @@
1
+ nxsconfigserver/ComponentParser.py,sha256=oUEy3_0Q77992pAxR3k8CxzF5UP4hwc2beHYh9v-mJU,7745
2
+ nxsconfigserver/Errors.py,sha256=zFZlQNbZV6UlbGGBV149j1DQbPXAkTmYVgaR1QRIXP8,1956
3
+ nxsconfigserver/MYSQLDataBase.py,sha256=54bFG4KFLMkVYMme3bcybve24qgsxKTvCo7vP6RDjTI,22755
4
+ nxsconfigserver/Merger.py,sha256=pNMvdSvx6sEBdg0qfsPKVOi5jkmAsihk-ZnSlkhtk0Q,26709
5
+ nxsconfigserver/NXSConfigServer.py,sha256=FlM3a1-kR7GE7tqtXv8HPNrAK0Nyjhpb4SXgUEkq5ok,49178
6
+ nxsconfigserver/Release.py,sha256=uFfx-sfwtaIt605eLxiPbBu_NPw6zPbhwWIYiQr8EY0,895
7
+ nxsconfigserver/StreamSet.py,sha256=sSvXJxoDufmt9_Xu5rFaQsp_4x9gww_zMv0NTiiyLlg,5799
8
+ nxsconfigserver/XMLConfigurator.py,sha256=cLiv0uKv6DnW9y6KBChOkXG6rXeVJZI2EY5tcS0vZTM,38983
9
+ nxsconfigserver/__init__.py,sha256=dAvNwdxRsIARsH--JgJBAxzyaX3KPzZNStQ6B7SLbjI,1718
10
+ nxsconfigserver-2.21.2.data/scripts/NXSConfigServer,sha256=VEAkby0R6UyckF-OofkVDPx3Mkn6rjPrl2xMbbBXqwo,986
11
+ nxsconfigserver-2.21.2.dist-info/METADATA,sha256=kadSUWGC_lH6z7SQGht4XBJ9PM6UEJQ6o5rfx7qk2-g,14580
12
+ nxsconfigserver-2.21.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
13
+ nxsconfigserver-2.21.2.dist-info/top_level.txt,sha256=TFz-xXdq3yV2iwY44R0uY1F-zqwYDnOmcJlN9kdo1S8,16
14
+ nxsconfigserver-2.21.2.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- nxsconfigserver/ComponentParser.py,sha256=oUEy3_0Q77992pAxR3k8CxzF5UP4hwc2beHYh9v-mJU,7745
2
- nxsconfigserver/Errors.py,sha256=zFZlQNbZV6UlbGGBV149j1DQbPXAkTmYVgaR1QRIXP8,1956
3
- nxsconfigserver/MYSQLDataBase.py,sha256=54bFG4KFLMkVYMme3bcybve24qgsxKTvCo7vP6RDjTI,22755
4
- nxsconfigserver/Merger.py,sha256=U8MHssm3j_LSXnaQWDrcsNL3WTCjGhndZk5ghX0lvZw,25734
5
- nxsconfigserver/NXSConfigServer.py,sha256=5zOFJXPfx9qu_pWCcvsCWluHsDfMOKRuAP5TUpuBtyI,48059
6
- nxsconfigserver/Release.py,sha256=ppIx2NmQN559RH_J9_oB6D0XxZ1haPI1F-OE7-JpN1c,895
7
- nxsconfigserver/StreamSet.py,sha256=sSvXJxoDufmt9_Xu5rFaQsp_4x9gww_zMv0NTiiyLlg,5799
8
- nxsconfigserver/XMLConfigurator.py,sha256=bWJuJHvHsXNKZuFAcXi_Er5O_ZhsR24FFOzoFubp3eg,37573
9
- nxsconfigserver/__init__.py,sha256=dAvNwdxRsIARsH--JgJBAxzyaX3KPzZNStQ6B7SLbjI,1718
10
- nxsconfigserver-2.20.0.data/scripts/NXSConfigServer,sha256=VEAkby0R6UyckF-OofkVDPx3Mkn6rjPrl2xMbbBXqwo,986
11
- nxsconfigserver-2.20.0.dist-info/METADATA,sha256=6hna9733z74TKnHve2Txd6uXsqcdS-_9ficmQumIT5c,14580
12
- nxsconfigserver-2.20.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
13
- nxsconfigserver-2.20.0.dist-info/top_level.txt,sha256=TFz-xXdq3yV2iwY44R0uY1F-zqwYDnOmcJlN9kdo1S8,16
14
- nxsconfigserver-2.20.0.dist-info/RECORD,,