nxsconfigserver 2.19.0__py3-none-any.whl → 2.21.1__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
@@ -77,6 +77,8 @@ class Merger(object):
77
77
 
78
78
  #: (:obj:`xml.etree.ElementTree.Element`) DOM root node
79
79
  self.__root = None
80
+ #: (:obj:`bool`) do not merge node on false
81
+ self.skip = False
80
82
  #: (:obj:`list` <:obj:`str`> ) tags which cannot have the same siblings
81
83
  self.singles = ['strategy', 'dimensions', 'definition',
82
84
  'record', 'device', 'query', 'database',
@@ -182,7 +184,7 @@ class Merger(object):
182
184
  res += ":" + name
183
185
  return res
184
186
 
185
- def __areMergeable(self, elem1, elem2, ancestors):
187
+ def __areMergeable(self, elem1, elem2, ancestors, node):
186
188
  """ checks if two elements are mergeable
187
189
 
188
190
  :param elem1: first element
@@ -214,20 +216,32 @@ class Merger(object):
214
216
  if tags:
215
217
  status = False
216
218
  if tagName in self.singles or (name1 and name1 == name2):
217
- raise IncompatibleNodeError(
218
- "Incompatible element attributes %s: %s"
219
- % (str(self.__getAncestors(elem1, ancestors)), str(tags)),
220
- [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
221
232
 
222
233
  if tagName in self.uniqueText:
223
234
  text1 = unicode(self.__getText(elem1)).strip()
224
235
  text2 = unicode(self.__getText(elem2)).strip()
225
236
  if text1 != text2 and text1 and text2:
226
- raise IncompatibleNodeError(
227
- "Incompatible \n%s element value\n%s \n%s "
228
- % (str(self.__getAncestors(elem1, ancestors)),
229
- text1, text2),
230
- [elem1, elem2])
237
+ if not self.skip:
238
+ raise IncompatibleNodeError(
239
+ "Incompatible \n%s element value\n%s \n%s "
240
+ % (str(self.__getAncestors(elem1, ancestors)),
241
+ text1, text2),
242
+ [elem1, elem2])
243
+ else:
244
+ status = False
231
245
  return status
232
246
 
233
247
  def __checkAttributes(self, elem1, elem2):
@@ -325,6 +339,9 @@ class Merger(object):
325
339
 
326
340
  children = list(node)
327
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)
328
345
  while c1 < len(children):
329
346
  child1 = children[c1]
330
347
  c2 = c1 + 1
@@ -333,7 +350,7 @@ class Merger(object):
333
350
  if child1 != child2:
334
351
  if self.__areMergeable(
335
352
  child1, child2,
336
- ancestors):
353
+ ancestors, node):
337
354
  self.__mergeNodes(child1, child2, node)
338
355
  children.pop(c2)
339
356
  c2 -= 1
@@ -354,8 +371,9 @@ class Merger(object):
354
371
 
355
372
  self.__mergeChildren(child, newancestors, entrynode,
356
373
  datanode, linknode)
357
- if cName in self.switchable and self.switchdatasources:
358
- self.__switch(child)
374
+ # if cName in self.switchable and self.switchdatasources:
375
+ # print("CHILD", child.tag, child.get("name"))
376
+ # self.__switch(child)
359
377
  if cName in self.linkable and self.linkdatasources:
360
378
  datanode = self.__addlink(
361
379
  child, newancestors, entrynode, datanode,
@@ -426,7 +444,8 @@ class Merger(object):
426
444
  :type node: :obj:`xml.etree.ElementTree.Element`
427
445
  """
428
446
  if node is not None:
429
- stnode = None
447
+ stnodes = []
448
+ modes = []
430
449
  mode = None
431
450
  dsname = None
432
451
  dsnode = None
@@ -451,13 +470,18 @@ class Merger(object):
451
470
  elif cName == 'strategy':
452
471
  mode = child.get("mode")
453
472
  if mode in self.modesToSwitch.keys():
454
- stnode = child
455
- else:
456
- break
457
- if stnode is not None and dsnode is not None:
458
- break
459
- if stnode is not None and dsnode is not None:
460
- 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)
461
485
 
462
486
  def __canfail(self, node):
463
487
  """ switch the given node to canfail mode
@@ -135,6 +135,26 @@ class NXSConfigServer(tango.LatestDeviceImpl):
135
135
  return False
136
136
  return True
137
137
 
138
+ def read_XMLCache(self, attr):
139
+ """ Read XMLCache attribute
140
+
141
+ :param attr: xml string attribute
142
+ :type attr: :class:`tango.Attribute`
143
+ """
144
+ self.debug_stream("In read_XMLCache()")
145
+ attr.set_value(self.xmlc.xmlcache)
146
+
147
+ def is_XMLCache_allowed(self, _):
148
+ """ XMLCache attribute State Machine
149
+
150
+ :returns: True if the operation allowed
151
+ :rtype: :obj:`bool`
152
+ """
153
+ if self.get_state() in [tango.DevState.ON,
154
+ tango.DevState.RUNNING]:
155
+ return False
156
+ return True
157
+
138
158
  def read_Selection(self, attr):
139
159
  """ Read Selection attribute
140
160
 
@@ -765,6 +785,7 @@ class NXSConfigServer(tango.LatestDeviceImpl):
765
785
 
766
786
  :brief: Creates the NDTS configuration script from the
767
787
  given components. The result is strored in XMLString
788
+ and XMLCache
768
789
 
769
790
  :param argin: DevVarStringArray list of component names
770
791
  :type argin: :obj:`list` <:obj:`str`>
@@ -789,6 +810,36 @@ class NXSConfigServer(tango.LatestDeviceImpl):
789
810
  return False
790
811
  return True
791
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
+
792
843
  def DeleteComponent(self, argin):
793
844
  """ DeleteComponent command
794
845
 
@@ -1255,6 +1306,9 @@ class NXSConfigServerClass(tango.DeviceClass):
1255
1306
  'CreateConfiguration':
1256
1307
  [[tango.DevVarStringArray, "list of component names"],
1257
1308
  [tango.DevVoid, ""]],
1309
+ 'CreateCache':
1310
+ [[tango.DevVarStringArray, "list of component names"],
1311
+ [tango.DevVoid, ""]],
1258
1312
  'DeleteComponent':
1259
1313
  [[tango.DevString, "component name"],
1260
1314
  [tango.DevVoid, ""]],
@@ -1316,6 +1370,16 @@ class NXSConfigServerClass(tango.DeviceClass):
1316
1370
  "it contains the resulting XML configuration.",
1317
1371
  'Display level': tango.DispLevel.EXPERT,
1318
1372
  }],
1373
+ 'XMLCache':
1374
+ [[tango.DevString,
1375
+ tango.SCALAR,
1376
+ tango.READ],
1377
+ {
1378
+ 'label': "XML for merged components",
1379
+ 'description':
1380
+ "XML for merged components without applied variables ",
1381
+ 'Display level': tango.DispLevel.EXPERT,
1382
+ }],
1319
1383
  'Selection':
1320
1384
  [[tango.DevString,
1321
1385
  tango.SCALAR,
@@ -20,4 +20,4 @@
20
20
  """ release version module """
21
21
 
22
22
  #: version number
23
- __version__ = "2.19.0"
23
+ __version__ = "2.21.1"
@@ -86,6 +86,8 @@ class XMLConfigurator(object):
86
86
  self._streams = StreamSet(weakref.ref(server) if server else None)
87
87
  #: (:obj:`str`) XML config string
88
88
  self.xmlstring = ""
89
+ #: (:obj:`str`) Merged coponents in XML string without variables
90
+ self.xmlcache = ""
89
91
  #: (:obj:`str`) component selection
90
92
  self.selection = "{}"
91
93
  #: (:obj:`str`) JSON string with arguments to connect to database
@@ -829,9 +831,12 @@ class XMLConfigurator(object):
829
831
  name = subc.strip() if subc else ""
830
832
  if name:
831
833
  if tag and name not in keys:
832
- raise NonregisteredDBRecordError(
833
- "The %s %s of %s not registered in the DataBase" % (
834
- 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))
835
840
  try:
836
841
  xmlds = funValue([name], defsubc)
837
842
  except Exception:
@@ -840,7 +845,7 @@ class XMLConfigurator(object):
840
845
  raise NonregisteredDBRecordError(
841
846
  "The %s %s of %s not registered" % (
842
847
  tag if tag else "variable", name, component))
843
- if tag:
848
+ if tag and xmlds:
844
849
  if sys.version_info > (3,):
845
850
  root = et.fromstring(
846
851
  bytes(xmlds[0], "UTF-8"),
@@ -906,10 +911,12 @@ class XMLConfigurator(object):
906
911
  component, self.__varLabel,
907
912
  list(self.__parameters.keys()), self.__getVariable)
908
913
 
909
- def __attachComponents(self, component):
914
+ def __attachComponents(self, component, onlyexisting=False):
910
915
  """ attaches variables to component
911
916
 
912
917
  :param component: given component
918
+ :param onlyexisting: attachElement only if exists
919
+ :type onlyexisting: :obj:`bool`
913
920
  :type component: :obj:`str`
914
921
  :returns: component with attached variables
915
922
  :rtype: :obj:`str`
@@ -917,13 +924,16 @@ class XMLConfigurator(object):
917
924
  if not component:
918
925
  return
919
926
  return self.__attachElements(
920
- component, self.__cpLabel, [], lambda x, y: [""])
927
+ component, self.__cpLabel, [], lambda x, y: [""],
928
+ onlyexisting=onlyexisting)
921
929
 
922
- def __attachDataSources(self, component):
930
+ def __attachDataSources(self, component, onlyexisting=False):
923
931
  """ attaches datasources to component
924
932
 
925
933
  :param component: given component
926
934
  :type component: :obj:`str`
935
+ :param onlyexisting: attachElement only if exists
936
+ :type onlyexisting: :obj:`bool`
927
937
  :returns: component with attached datasources
928
938
  :rtype: :obj:`str`
929
939
  """
@@ -932,7 +942,7 @@ class XMLConfigurator(object):
932
942
  return self.__attachElements(
933
943
  component, self.__dsLabel,
934
944
  self.availableDataSources(), self.dataSources,
935
- "datasource")
945
+ "datasource", onlyexisting=onlyexisting)
936
946
 
937
947
  def merge(self, names):
938
948
  """ merges the give components
@@ -961,13 +971,15 @@ class XMLConfigurator(object):
961
971
  cpvars[str(key)] = str(value)
962
972
  return cpvars
963
973
 
964
- def __mergeVars(self, names, withVariables=False):
974
+ def __mergeVars(self, names, withVariables=False, onlyCache=False):
965
975
  """ merges the give components
966
976
 
967
977
  :param names: list of component names
968
978
  :type names: :obj:`list` <:obj:`str`>
969
979
  :param withVariables: if true variables will be substituted
970
980
  :param withVariables: :obj:`bool`
981
+ :param onlyCache: if true create only cache
982
+ :param onlyCache: :obj:`bool`
971
983
  :returns: merged components
972
984
  :rtype: :obj:`str`
973
985
  """
@@ -976,13 +988,23 @@ class XMLConfigurator(object):
976
988
  allnames = self.dependentComponents(
977
989
  list(set(self.__mydb.mandatory() + names)))
978
990
  comps = self.__mydb.components(list(set(allnames)))
991
+ xml = self.__merge(comps, skip=withVariables)
979
992
  if withVariables:
980
- cpvars = self.__variableComponentValues(comps)
981
- comps = [self.__attachVariables(cp, cpvars) for cp in comps]
982
- xml = self.__merge(comps)
993
+ xml = self.__attachDataSources(
994
+ self.__attachComponents(
995
+ xml, onlyexisting=True), onlyexisting=True)
996
+ self.xmlcache = xml or ""
997
+ if onlyCache:
998
+ return self.xmlcache
999
+ if xml is not None:
1000
+ comps = [xml]
1001
+ cpvars = self.__variableComponentValues(comps)
1002
+ comps = [self.__attachVariables(cp, cpvars)
1003
+ for cp in comps]
1004
+ xml = self.__merge(comps)
983
1005
  return xml if xml is not None else ""
984
1006
 
985
- def __merge(self, xmls):
1007
+ def __merge(self, xmls, skip=False):
986
1008
  """ merges the give component xmls
987
1009
 
988
1010
  :param xmls: list of component xmls
@@ -991,11 +1013,13 @@ class XMLConfigurator(object):
991
1013
  :rtype: :obj:`str`
992
1014
  """
993
1015
  mgr = Merger()
994
- mgr.switchdatasources = json.loads(self.stepdatasources)
995
- mgr.linkdatasources = json.loads(self.linkdatasources)
996
- mgr.extralinkdatasources = json.loads(self.extralinkdatasources)
997
- mgr.canfaildatasources = json.loads(self.canfaildatasources)
998
- mgr.extralinkpath = self.__splitExtraPath(self.extraLinkPath)
1016
+ if not skip:
1017
+ mgr.switchdatasources = json.loads(self.stepdatasources)
1018
+ mgr.linkdatasources = json.loads(self.linkdatasources)
1019
+ mgr.extralinkdatasources = json.loads(self.extralinkdatasources)
1020
+ mgr.canfaildatasources = json.loads(self.canfaildatasources)
1021
+ mgr.extralinkpath = self.__splitExtraPath(self.extraLinkPath)
1022
+ mgr.skip = skip
999
1023
  mgr.collect(xmls)
1000
1024
  mgr.merge()
1001
1025
  return mgr.toString()
@@ -1027,6 +1051,16 @@ class XMLConfigurator(object):
1027
1051
  epath.append([nd[0], "NX" + nd[0]])
1028
1052
  return epath
1029
1053
 
1054
+ def createCache(self, names):
1055
+ """ creates the final configuration string in the xmlstring attribute
1056
+
1057
+ :param names: list of component names
1058
+ :type names: :obj:`list` <:obj:`str`>
1059
+ """
1060
+ self.__mergeVars(names, withVariables=True, onlyCache=True)
1061
+ self._streams.info("XMLConfigurator::createConfiguration() "
1062
+ "- Create configuration")
1063
+
1030
1064
  def createConfiguration(self, names):
1031
1065
  """ creates the final configuration string in the xmlstring attribute
1032
1066
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nxsconfigserver
3
- Version: 2.19.0
3
+ Version: 2.21.1
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
@@ -99,21 +99,22 @@ with proper privileges.
99
99
  Debian packages
100
100
  ^^^^^^^^^^^^^^^
101
101
 
102
- Debian Bookworm, Bullseye, Buster and as well as Ubuntu Plucky, Noble, Jammy packages can be found in the HDRI repository.
102
+ Debian Trixie, Bookworm, Bullseye and as well as Ubuntu Questing, Noble, Jammy packages can be found in the HDRI repository.
103
103
 
104
104
  To install the debian packages, add the PGP repository key
105
105
 
106
106
  .. code-block:: console
107
107
 
108
108
  $ sudo su
109
- $ wget -q -O - http://repos.pni-hdri.de/debian_repo.pub.gpg | apt-key add -
109
+ $ curl -s http://repos.pni-hdri.de/debian_repo.pub.gpg | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/debian-hdri-repo.gpg --import
110
+ $ chmod 644 /etc/apt/trusted.gpg.d/debian-hdri-repo.gpg
110
111
 
111
- and then download the corresponding source list, e.g. for bookworm
112
+ and then download the corresponding source list, e.g. for trixie
112
113
 
113
114
  .. code-block:: console
114
115
 
115
116
  $ cd /etc/apt/sources.list.d
116
- $ wget http://repos.pni-hdri.de/bookworm-pni-hdri.list
117
+ $ wget http://repos.pni-hdri.de/trixie-pni-hdri.sources
117
118
 
118
119
  Finally, for python2 packages
119
120
 
@@ -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=2qnNjn98r87uukmyURh0Is97f_sXSr5U6M81cqVSsTw,895
7
+ nxsconfigserver/StreamSet.py,sha256=sSvXJxoDufmt9_Xu5rFaQsp_4x9gww_zMv0NTiiyLlg,5799
8
+ nxsconfigserver/XMLConfigurator.py,sha256=OVQiDrWuCX2Ta8MtycTvoc3yKankfsVbZTQd6gQ6ktM,38785
9
+ nxsconfigserver/__init__.py,sha256=dAvNwdxRsIARsH--JgJBAxzyaX3KPzZNStQ6B7SLbjI,1718
10
+ nxsconfigserver-2.21.1.data/scripts/NXSConfigServer,sha256=VEAkby0R6UyckF-OofkVDPx3Mkn6rjPrl2xMbbBXqwo,986
11
+ nxsconfigserver-2.21.1.dist-info/METADATA,sha256=kNl7pYZ4HRXl4ONHIDi6Icto6MnyL-s6W3NvrZR5hbk,14580
12
+ nxsconfigserver-2.21.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
13
+ nxsconfigserver-2.21.1.dist-info/top_level.txt,sha256=TFz-xXdq3yV2iwY44R0uY1F-zqwYDnOmcJlN9kdo1S8,16
14
+ nxsconfigserver-2.21.1.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=r7SS4JRdFWgGgRuI1sDl-H-zsYVcUjIbF3mSlTG_CHk,25545
5
- nxsconfigserver/NXSConfigServer.py,sha256=kxHx0vugHEin9j5c0iizvIbbi0Z5S6E8MoMDY7csN6k,47113
6
- nxsconfigserver/Release.py,sha256=2KgnY_sm1tpwteaOQR6sXxvJM1opn5jyjKBMrQO7erQ,895
7
- nxsconfigserver/StreamSet.py,sha256=sSvXJxoDufmt9_Xu5rFaQsp_4x9gww_zMv0NTiiyLlg,5799
8
- nxsconfigserver/XMLConfigurator.py,sha256=xdifnewlTNIQ3PgHTBvBh83xJUf2qCnqC3Rkq24urzk,37220
9
- nxsconfigserver/__init__.py,sha256=dAvNwdxRsIARsH--JgJBAxzyaX3KPzZNStQ6B7SLbjI,1718
10
- nxsconfigserver-2.19.0.data/scripts/NXSConfigServer,sha256=VEAkby0R6UyckF-OofkVDPx3Mkn6rjPrl2xMbbBXqwo,986
11
- nxsconfigserver-2.19.0.dist-info/METADATA,sha256=9C9T_WGxRBExhkI-YFFnZkhvJceog6scmyOJYRu57DA,14440
12
- nxsconfigserver-2.19.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
13
- nxsconfigserver-2.19.0.dist-info/top_level.txt,sha256=TFz-xXdq3yV2iwY44R0uY1F-zqwYDnOmcJlN9kdo1S8,16
14
- nxsconfigserver-2.19.0.dist-info/RECORD,,