From c0c926d9d71200f65c5096314625eb3aa2f8c3c5 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Fri, 22 Nov 2019 09:05:15 +0100 Subject: [PATCH] configurables must contain only settable properties + bug fix in TCLRequestHandler (decoding error) + cosmetic changes Change-Id: I824e06f1acf975bb59c3312bb97fdfca23e6c975 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21826 Tested-by: JenkinsCodeReview Reviewed-by: Markus Zolliker --- secop/metaclass.py | 6 ++++-- secop/modules.py | 7 +++---- secop/protocol/interface/tcp.py | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/secop/metaclass.py b/secop/metaclass.py index 8d42862..b351176 100644 --- a/secop/metaclass.py +++ b/secop/metaclass.py @@ -194,10 +194,12 @@ class ModuleMeta(PropertyMeta): res = {} # collect info about properties for pn, pv in cls.properties.items(): - res[pn] = pv + if pv.settable: + res[pn] = pv # collect info about parameters and their properties for param, pobj in cls.accessibles.items(): res[param] = {} for pn, pv in pobj.getProperties().items(): - res[param][pn] = pv + if pv.settable: + res[param][pn] = pv return res diff --git a/secop/modules.py b/secop/modules.py index 6ca772f..5d3dfad 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -198,10 +198,9 @@ class Module(HasProperties, metaclass=ModuleMeta): except (ValueError, TypeError): self.log.exception(formatExtendedStack()) raise -# raise ConfigError('Module %s: config parameter %r:\n%r' % -# (self.name, k, e)) - # note: this will call write_* methods which will - # write to the hardware, if possible! + # raise ConfigError('Module %s: config parameter %r:\n%r' % + # (self.name, k, e)) + # note: this will NOT call write_* methods! if k != 'value': setattr(self, k, v) cfgdict.pop(k) diff --git a/secop/protocol/interface/tcp.py b/secop/protocol/interface/tcp.py index e90ec63..6b61a7d 100644 --- a/secop/protocol/interface/tcp.py +++ b/secop/protocol/interface/tcp.py @@ -122,7 +122,8 @@ class TCPRequestHandler(socketserver.BaseRequestHandler): try: msg = decode_msg(origin) except Exception as err: - msg = origin.split(' ',3) + # we have to decode 'origin' here. utf-8 and ascii may lead to encoding errors + msg = origin.decode('latin-1').split(' ', 3) result = (ERRORPREFIX + msg[0], msg[1], ['InternalError', str(err), {'exception': formatException(), 'traceback': formatExtendedStack()}])