diff --git a/secop/basic_validators.py b/secop/basic_validators.py index ff055f9..05a7548 100644 --- a/secop/basic_validators.py +++ b/secop/basic_validators.py @@ -21,6 +21,8 @@ # ***************************************************************************** """basic validators (for properties)""" +# TODO: remove, as not used anymore + import re diff --git a/secop/client/__init__.py b/secop/client/__init__.py index b4e9922..c1d22b4 100644 --- a/secop/client/__init__.py +++ b/secop/client/__init__.py @@ -31,7 +31,7 @@ from threading import Event, RLock, current_thread import secop.errors import secop.params from secop.datatypes import get_datatype -from secop.lib import formatExtendedStack, formatExtendedTraceback, mkthread +from secop.lib import mkthread from secop.lib.asynconn import AsynConn, ConnectionClosed from secop.protocol.interface import decode_msg, encode_msg_frame from secop.protocol.messages import COMMANDREQUEST, \ @@ -161,7 +161,6 @@ class ProxyClient: if not cblist: self.callbacks[cbname].pop(key) - def callback(self, key, cbname, *args): """perform callbacks diff --git a/secop/client/baseclient.py b/secop/client/baseclient.py index cea01f9..72bfe42 100644 --- a/secop/client/baseclient.py +++ b/secop/client/baseclient.py @@ -21,6 +21,8 @@ # ***************************************************************************** """Define Client side proxies""" +# TODO: remove, as currently not used + import json import queue @@ -48,7 +50,6 @@ except ImportError: pass - class TCPConnection: # disguise a TCP connection as serial one diff --git a/secop/client/console.py b/secop/client/console.py index 0e7cf0f..b466a02 100644 --- a/secop/client/console.py +++ b/secop/client/console.py @@ -21,7 +21,7 @@ # ***************************************************************************** """console client""" -# this needs to be reworked or removed +# TODO: remove, as currently not used import code diff --git a/secop/errors.py b/secop/errors.py index 3cbbda3..53300e7 100644 --- a/secop/errors.py +++ b/secop/errors.py @@ -22,7 +22,6 @@ """Define (internal) SECoP Errors""" - class SECoPError(RuntimeError): def __init__(self, *args, **kwds): diff --git a/secop/gui/cfg_editor/config_file.py b/secop/gui/cfg_editor/config_file.py index ea0c48c..3418e12 100644 --- a/secop/gui/cfg_editor/config_file.py +++ b/secop/gui/cfg_editor/config_file.py @@ -58,7 +58,7 @@ def write_config(file_name, tree_widget): value = value.replace('\n\n', '\n.\n') value = value.replace('\n', '\n ') itm_lines[id(itm)] = '[%s %s]\n' % (itm.kind, itm.name) +\ - value_str % (SECTIONS[itm.kind], value) + value_str % (SECTIONS[itm.kind], value) # TODO params and props elif itm.kind == PARAMETER and value: itm_lines[id(itm)] = value_str % (itm.name, value) @@ -142,7 +142,7 @@ def read_config(file_path): else: param.addChild(TreeWidgetItem(PROPERTY, separated[1], get_value(config, section, - option))) + option))) node = get_comments(node, ifs, mods, file_path) return node, ifs, mods diff --git a/secop/gui/mainwindow.py b/secop/gui/mainwindow.py index c3f605d..3399eba 100644 --- a/secop/gui/mainwindow.py +++ b/secop/gui/mainwindow.py @@ -90,7 +90,7 @@ class QSECNode(QObject): def queryCache(self, module): return {k: Value(*self.conn.cache[(module, k)]) - for k in self.modules[module]['parameters']} + for k in self.modules[module]['parameters']} def syncCommunicate(self, action, ident='', data=None): reply = self.conn.request(action, ident, data) diff --git a/secop/gui/modulectrl.py b/secop/gui/modulectrl.py index 700e25b..4c54d86 100644 --- a/secop/gui/modulectrl.py +++ b/secop/gui/modulectrl.py @@ -36,19 +36,19 @@ class CommandDialog(QDialog): loadUi(self, 'cmddialog.ui') self.setWindowTitle('Arguments for %s' % cmdname) - #row = 0 + # row = 0 self._labels = [] self.widgets = [] # improve! recursive? dtype = argument - l = QLabel(repr(dtype)) - l.setWordWrap(True) - w = get_widget(dtype, readonly=False) - self.gridLayout.addWidget(l, 0, 0) - self.gridLayout.addWidget(w, 0, 1) - self._labels.append(l) - self.widgets.append(w) + label = QLabel(repr(dtype)) + label.setWordWrap(True) + widget = get_widget(dtype, readonly=False) + self.gridLayout.addWidget(label, 0, 0) + self.gridLayout.addWidget(widget, 0, 1) + self._labels.append(label) + self.widgets.append(widget) self.gridLayout.setRowStretch(1, 1) self.setModal(True) diff --git a/secop/gui/nodectrl.py b/secop/gui/nodectrl.py index cc0c303..af6d3da 100644 --- a/secop/gui/nodectrl.py +++ b/secop/gui/nodectrl.py @@ -168,7 +168,6 @@ class NodeCtrl(QWidget): print(secop.lib.formatExtendedTraceback()) widget = QLabel('Bad configured Module %s! (%s)' % (modname, e)) - if unit: labelstr = '%s (%s):' % (modname, unit) else: @@ -290,7 +289,7 @@ class DrivableWidget(ReadableWidget): def update_current(self, value): self.currentLineEdit.setText(str(value)) - #elif self._is_enum: + # elif self._is_enum: # member = self._map[self._revmap[value.value]] # self.currentLineEdit.setText('%s.%s (%d)' % (member.enum.name, member.name, member.value)) diff --git a/secop/gui/params/__init__.py b/secop/gui/params/__init__.py index 5ac5038..92e5584 100644 --- a/secop/gui/params/__init__.py +++ b/secop/gui/params/__init__.py @@ -22,12 +22,9 @@ # ***************************************************************************** -from secop.datatypes import EnumType, FloatRange, IntRange -from secop.gui.qt import QCheckBox, QLabel, QLineEdit, QMessageBox -from secop.gui.qt import QPushButton as QButton -from secop.gui.qt import QSizePolicy, Qt, QWidget, pyqtSignal, pyqtSlot +from secop.datatypes import EnumType +from secop.gui.qt import QWidget, pyqtSignal, pyqtSlot from secop.gui.util import loadUi -from secop.lib import formatExtendedStack class ParameterWidget(QWidget): diff --git a/secop/gui/util.py b/secop/gui/util.py index 4e24b62..e908733 100644 --- a/secop/gui/util.py +++ b/secop/gui/util.py @@ -32,6 +32,7 @@ uipath = path.dirname(__file__) def loadUi(widget, uiname, subdir='ui'): uic.loadUi(path.join(uipath, subdir, uiname), widget) + class Value: def __init__(self, value, timestamp=None, readerror=None): self.value = value diff --git a/secop/gui/valuewidgets.py b/secop/gui/valuewidgets.py index e4ad5ca..856e6bb 100644 --- a/secop/gui/valuewidgets.py +++ b/secop/gui/valuewidgets.py @@ -29,6 +29,7 @@ from secop.gui.qt import QCheckBox, QComboBox, QDialog, \ QLabel, QLineEdit, QSpinBox, QTextEdit, QVBoxLayout from secop.gui.util import loadUi + # XXX: implement live validators !!!! # XXX: signals upon change of value # XXX: honor readonly in all cases! @@ -171,12 +172,12 @@ class StructWidget(QGroupBox): self._labels = [] for idx, name in enumerate(sorted(datatype.members)): dt = datatype.members[name] - w = get_widget(dt, readonly=readonly, parent=self) - l = QLabel(name) - self.layout.addWidget(l, idx, 0) - self.layout.addWidget(w, idx, 1) - self._labels.append(l) - self.subwidgets[name] = (w, dt) + widget = get_widget(dt, readonly=readonly, parent=self) + label = QLabel(name) + self.layout.addWidget(label, idx, 0) + self.layout.addWidget(widget, idx, 1) + self._labels.append(label) + self.subwidgets[name] = (widget, dt) self.datatypes.append(dt) self.setLayout(self.layout) @@ -215,21 +216,22 @@ class ArrayWidget(QGroupBox): w.set_value(v) - def get_widget(datatype, readonly=False, parent=None): - return {FloatRange: FloatWidget, - IntRange: IntWidget, - StringType: StringWidget, - TextType: TextWidget, - BLOBType: BlobWidget, - EnumType: EnumWidget, - BoolType: BoolWidget, - TupleOf: TupleWidget, - StructOf: StructWidget, - ArrayOf: ArrayWidget, + return { + FloatRange: FloatWidget, + IntRange: IntWidget, + StringType: StringWidget, + TextType: TextWidget, + BLOBType: BlobWidget, + EnumType: EnumWidget, + BoolType: BoolWidget, + TupleOf: TupleWidget, + StructOf: StructWidget, + ArrayOf: ArrayWidget, }.get(datatype.__class__)(datatype, readonly, parent) # TODO: handle NoneOr + class msg(QDialog): def __init__(self, stuff, parent=None): super(msg, self).__init__(parent) @@ -242,7 +244,7 @@ class msg(QDialog): dt = StructOf(i=IntRange(0, 10), f=FloatRange(), b=BoolType()) w = StructWidget(dt) self.gridLayout.addWidget(w, row, 1) - row+=1 + row += 1 self.gridLayout.addWidget(QLabel('stuff'), row, 0, 1, 0) row += 1 # at pos (0,0) span 2 cols, 1 row diff --git a/secop/lib/__init__.py b/secop/lib/__init__.py index 40ac337..ad3df26 100644 --- a/secop/lib/__init__.py +++ b/secop/lib/__init__.py @@ -58,6 +58,7 @@ CONFIG['basedir'] = repodir unset_value = object() + class lazy_property: """A property that calculates its value only once.""" diff --git a/secop/lib/asynconn.py b/secop/lib/asynconn.py index 83e7ffd..348f971 100644 --- a/secop/lib/asynconn.py +++ b/secop/lib/asynconn.py @@ -62,10 +62,10 @@ class AsynConn: except (ValueError, TypeError, AssertionError): if 'COM' in uri: raise ValueError("the correct uri for a COM port is: " - "'serial://COM[?