From 153b4d79f7406195c4d51047e77e8ae4d5fb59c2 Mon Sep 17 00:00:00 2001 From: Enrico Faulhaber Date: Thu, 26 Apr 2018 16:14:19 +0200 Subject: [PATCH] fix equipment_id handling Change-Id: Ibeba9f0771dca8e7f9754f8b6431535885d654a0 Reviewed-on: https://forge.frm2.tum.de/review/17857 Tested-by: JenkinsCodeReview Reviewed-by: Enrico Faulhaber Tested-by: Enrico Faulhaber --- secop/client/baseclient.py | 13 ++++++------- secop/gui/mainwindow.py | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/secop/client/baseclient.py b/secop/client/baseclient.py index bb5c409..1495cf6 100644 --- a/secop/client/baseclient.py +++ b/secop/client/baseclient.py @@ -161,7 +161,6 @@ class Value(object): class Client(object): - equipment_id = 'unknown' secop_id = 'unknown' describing_data = {} stopflag = False @@ -313,15 +312,13 @@ class Client(object): self.log.warning("deprecated specifier %r" % spec) spec = '%s:value' % spec modname, pname = spec.split(':', 1) -# previous = '' -# if modname in self._cache: -# if pname in self._cache: -# previous = self._cache[modname][pname] + if data: self._cache.setdefault(modname, {})[pname] = Value(*data) else: self.log.warning( 'got malformed answer! (%s,%s)' % (spec, data)) + # self.log.info('cache: %s:%s=%r (was: %s)', modname, pname, data, previous) if spec in self.callbacks: for func in self.callbacks[spec]: @@ -367,7 +364,7 @@ class Client(object): return result def _issueDescribe(self): - _, self.equipment_id, describing_data = self._communicate('describe') + _, _, describing_data = self._communicate('describe') try: describing_data = self._decode_substruct( ['modules'], describing_data) @@ -535,7 +532,9 @@ class Client(object): @property def equipmentId(self): - return self.equipment_id + if self.describingData: + return self.describingData['properties']['equipment_id'] + return 'Undetermined' @property def protocolVersion(self): diff --git a/secop/gui/mainwindow.py b/secop/gui/mainwindow.py index 733be9d..f723e77 100644 --- a/secop/gui/mainwindow.py +++ b/secop/gui/mainwindow.py @@ -151,7 +151,7 @@ class MainWindow(QMainWindow): node = QSECNode({'connectto': host, 'port': port}, parent=self) host = '%s:%d' % (host, port) - host = '%s (%s)' % (node.equipment_id, host) + host = '%s (%s)' % (node.equipmentId, host) self._nodes[host] = node node.register_shutdown_callback(self._nodeDisconnected_callback, host)