further fixes of py3 issues
complaints by pylint are mainly related to - remove object from base list in class definitions - unnecessary else/elif after return/raise Change-Id: I13d15449149cc8bba0562338d0c9c42e97163bdf Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21325 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
70a9c42a7a
commit
c1164568ae
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# pylint: disable=invalid-name
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# pylint: disable=invalid-name
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
#
|
#
|
||||||
@ -21,7 +22,6 @@
|
|||||||
#
|
#
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
from os import path
|
from os import path
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# pylint: disable=invalid-name
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
#
|
#
|
||||||
@ -22,7 +23,6 @@
|
|||||||
#
|
#
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
from os import path
|
from os import path
|
||||||
|
@ -74,7 +74,7 @@ def getClientOpts(cfgfile):
|
|||||||
return dict(item for item in parser.items('client'))
|
return dict(item for item in parser.items('client'))
|
||||||
|
|
||||||
|
|
||||||
class ClientConsole(object):
|
class ClientConsole:
|
||||||
|
|
||||||
def __init__(self, cfgname, basepath):
|
def __init__(self, cfgname, basepath):
|
||||||
self.namespace = NameSpace()
|
self.namespace = NameSpace()
|
||||||
@ -99,7 +99,7 @@ class ClientConsole(object):
|
|||||||
help(arg)
|
help(arg)
|
||||||
|
|
||||||
|
|
||||||
class TCPConnection(object):
|
class TCPConnection:
|
||||||
|
|
||||||
def __init__(self, connect, port, **kwds):
|
def __init__(self, connect, port, **kwds):
|
||||||
self.log = mlzlog.log.getChild('connection', False)
|
self.log = mlzlog.log.getChild('connection', False)
|
||||||
@ -173,7 +173,7 @@ class TCPConnection(object):
|
|||||||
self.callbacks.discard(callback)
|
self.callbacks.discard(callback)
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client:
|
||||||
|
|
||||||
def __init__(self, opts):
|
def __init__(self, opts):
|
||||||
self.log = mlzlog.log.getChild('client', True)
|
self.log = mlzlog.log.getChild('client', True)
|
||||||
|
@ -44,7 +44,7 @@ from secop.protocol.messages import BUFFERREQUEST, COMMANDREQUEST, \
|
|||||||
READREQUEST, REQUEST2REPLY, WRITEREPLY, WRITEREQUEST
|
READREQUEST, REQUEST2REPLY, WRITEREPLY, WRITEREQUEST
|
||||||
|
|
||||||
|
|
||||||
class TCPConnection(object):
|
class TCPConnection:
|
||||||
# disguise a TCP connection as serial one
|
# disguise a TCP connection as serial one
|
||||||
|
|
||||||
def __init__(self, host, port):
|
def __init__(self, host, port):
|
||||||
@ -136,7 +136,7 @@ class TCPConnection(object):
|
|||||||
self.writeline(line)
|
self.writeline(line)
|
||||||
|
|
||||||
|
|
||||||
class Value(object):
|
class Value:
|
||||||
t = None # pylint: disable = C0103
|
t = None # pylint: disable = C0103
|
||||||
u = None
|
u = None
|
||||||
e = None
|
e = None
|
||||||
@ -165,7 +165,7 @@ class Value(object):
|
|||||||
return self.fmtstr % self.value
|
return self.fmtstr % self.value
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client:
|
||||||
secop_id = 'unknown'
|
secop_id = 'unknown'
|
||||||
describing_data = {}
|
describing_data = {}
|
||||||
stopflag = False
|
stopflag = False
|
||||||
@ -175,7 +175,7 @@ class Client(object):
|
|||||||
if 'testing' not in opts:
|
if 'testing' not in opts:
|
||||||
self.log = mlzlog.log.getChild('client', True)
|
self.log = mlzlog.log.getChild('client', True)
|
||||||
else:
|
else:
|
||||||
class logStub(object):
|
class logStub:
|
||||||
|
|
||||||
def info(self, *args):
|
def info(self, *args):
|
||||||
pass
|
pass
|
||||||
|
@ -48,7 +48,7 @@ DEFAULT_MAX_INT = 16777216
|
|||||||
Parser = Parser()
|
Parser = Parser()
|
||||||
|
|
||||||
# base class for all DataTypes
|
# base class for all DataTypes
|
||||||
class DataType(object):
|
class DataType:
|
||||||
IS_COMMAND = False
|
IS_COMMAND = False
|
||||||
unit = ''
|
unit = ''
|
||||||
fmtstr = '%r'
|
fmtstr = '%r'
|
||||||
@ -353,7 +353,7 @@ class EnumType(DataType):
|
|||||||
|
|
||||||
|
|
||||||
class BLOBType(DataType):
|
class BLOBType(DataType):
|
||||||
minbytes = None
|
minbytes = 0
|
||||||
maxbytes = None
|
maxbytes = None
|
||||||
|
|
||||||
def __init__(self, minbytes=0, maxbytes=None):
|
def __init__(self, minbytes=0, maxbytes=None):
|
||||||
@ -366,7 +366,7 @@ class BLOBType(DataType):
|
|||||||
self.maxbytes = int(maxbytes)
|
self.maxbytes = int(maxbytes)
|
||||||
if self.minbytes < 0:
|
if self.minbytes < 0:
|
||||||
raise BadValueError('sizes must be bigger than or equal to 0!')
|
raise BadValueError('sizes must be bigger than or equal to 0!')
|
||||||
elif self.minbytes > self.maxbytes:
|
if self.minbytes > self.maxbytes:
|
||||||
raise BadValueError('maxbytes must be bigger than or equal to minbytes!')
|
raise BadValueError('maxbytes must be bigger than or equal to minbytes!')
|
||||||
self.default = b'\0' * self.minbytes
|
self.default = b'\0' * self.minbytes
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ class StringType(DataType):
|
|||||||
self.set_prop('isUTF8', isUTF8, False, bool)
|
self.set_prop('isUTF8', isUTF8, False, bool)
|
||||||
if self.minchars < 0:
|
if self.minchars < 0:
|
||||||
raise BadValueError('sizes must be bigger than or equal to 0!')
|
raise BadValueError('sizes must be bigger than or equal to 0!')
|
||||||
elif self.minchars > self.maxchars:
|
if self.minchars > self.maxchars:
|
||||||
raise BadValueError('maxchars must be bigger than or equal to minchars!')
|
raise BadValueError('maxchars must be bigger than or equal to minchars!')
|
||||||
self.default = ' ' * self.minchars
|
self.default = ' ' * self.minchars
|
||||||
|
|
||||||
@ -504,7 +504,7 @@ class BoolType(DataType):
|
|||||||
|
|
||||||
def export_value(self, value):
|
def export_value(self, value):
|
||||||
"""returns a python object fit for serialisation"""
|
"""returns a python object fit for serialisation"""
|
||||||
return True if self(value) else False
|
return bool(self(value))
|
||||||
|
|
||||||
def import_value(self, value):
|
def import_value(self, value):
|
||||||
"""returns a python object from serialisation"""
|
"""returns a python object from serialisation"""
|
||||||
@ -544,9 +544,9 @@ class ArrayOf(DataType):
|
|||||||
self.maxlen = int(maxlen)
|
self.maxlen = int(maxlen)
|
||||||
if self.minlen < 0:
|
if self.minlen < 0:
|
||||||
raise BadValueError('sizes must be > 0')
|
raise BadValueError('sizes must be > 0')
|
||||||
elif self.maxlen < 1:
|
if self.maxlen < 1:
|
||||||
raise BadValueError('Maximum size must be >= 1!')
|
raise BadValueError('Maximum size must be >= 1!')
|
||||||
elif self.minlen > self.maxlen:
|
if self.minlen > self.maxlen:
|
||||||
raise BadValueError('maxlen must be bigger than or equal to minlen!')
|
raise BadValueError('maxlen must be bigger than or equal to minlen!')
|
||||||
self.default = [members.default] * self.minlen
|
self.default = [members.default] * self.minlen
|
||||||
|
|
||||||
@ -890,7 +890,7 @@ DATATYPES = dict(
|
|||||||
blob =lambda maxbytes, minbytes=0: BLOBType(minbytes=minbytes, maxbytes=maxbytes),
|
blob =lambda maxbytes, minbytes=0: BLOBType(minbytes=minbytes, maxbytes=maxbytes),
|
||||||
string =lambda minchars=0, maxchars=None: StringType(minchars=minchars, maxchars=maxchars),
|
string =lambda minchars=0, maxchars=None: StringType(minchars=minchars, maxchars=maxchars),
|
||||||
array =lambda maxlen, members, minlen=0: ArrayOf(get_datatype(members), minlen=minlen, maxlen=maxlen),
|
array =lambda maxlen, members, minlen=0: ArrayOf(get_datatype(members), minlen=minlen, maxlen=maxlen),
|
||||||
tuple =lambda members: TupleOf(*map(get_datatype, members)),
|
tuple =lambda members: TupleOf(*tuple(map(get_datatype, members))),
|
||||||
enum =lambda members: EnumType('', members=members),
|
enum =lambda members: EnumType('', members=members),
|
||||||
struct =lambda members, optional=None: StructOf(optional,
|
struct =lambda members, optional=None: StructOf(optional,
|
||||||
**dict((n, get_datatype(t)) for n, t in list(members.items()))),
|
**dict((n, get_datatype(t)) for n, t in list(members.items()))),
|
||||||
|
@ -28,9 +28,8 @@ from secop.metaclass import ModuleMeta
|
|||||||
from secop.modules import Command, Parameter
|
from secop.modules import Command, Parameter
|
||||||
|
|
||||||
|
|
||||||
class Feature(object, metaclass=ModuleMeta):
|
class Feature(metaclass=ModuleMeta):
|
||||||
"""all things belonging to a small, predefined functionality influencing the working of a module"""
|
"""all things belonging to a small, predefined functionality influencing the working of a module"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class HAS_PID(Feature):
|
class HAS_PID(Feature):
|
||||||
|
@ -136,7 +136,7 @@ class MainWindow(QMainWindow):
|
|||||||
reply = self.show_save_message(self.tabWidget.tabText(index))
|
reply = self.show_save_message(self.tabWidget.tabText(index))
|
||||||
if reply == QMessageBox.Cancel:
|
if reply == QMessageBox.Cancel:
|
||||||
return
|
return
|
||||||
elif reply == QMessageBox.Save:
|
if reply == QMessageBox.Save:
|
||||||
self.save_tab(index)
|
self.save_tab(index)
|
||||||
self.tabWidget.removeTab(index)
|
self.tabWidget.removeTab(index)
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ class MainWindow(QMainWindow):
|
|||||||
if reply == QMessageBox.Cancel:
|
if reply == QMessageBox.Cancel:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
elif reply == QMessageBox.Save:
|
if reply == QMessageBox.Save:
|
||||||
for i in range(0, self.tabWidget.count()):
|
for i in range(0, self.tabWidget.count()):
|
||||||
self.save_tab(i)
|
self.save_tab(i)
|
||||||
event.accept()
|
event.accept()
|
||||||
|
@ -28,7 +28,7 @@ class NodeDisplay(QWidget):
|
|||||||
def __init__(self, file_path=None, parent=None):
|
def __init__(self, file_path=None, parent=None):
|
||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
loadUi(self, 'node_display.ui')
|
loadUi(self, 'node_display.ui')
|
||||||
self.saved = True if file_path else False
|
self.saved = bool(file_path)
|
||||||
self.created = self.tree_widget.set_file(file_path)
|
self.created = self.tree_widget.set_file(file_path)
|
||||||
self.tree_widget.save_status_changed.connect(self.change_save_status)
|
self.tree_widget.save_status_changed.connect(self.change_save_status)
|
||||||
self.tree_widget.currentItemChanged.connect(self.set_scroll_area)
|
self.tree_widget.currentItemChanged.connect(self.set_scroll_area)
|
||||||
|
@ -104,7 +104,6 @@ class TreeWidget(QTreeWidget):
|
|||||||
self.set_tree(read_config(self.file_path))
|
self.set_tree(read_config(self.file_path))
|
||||||
self.emit_save_status_changed(True)
|
self.emit_save_status_changed(True)
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
self.file_path = None
|
self.file_path = None
|
||||||
return self.new_tree()
|
return self.new_tree()
|
||||||
|
|
||||||
@ -391,7 +390,7 @@ class AddDialog(QDialog):
|
|||||||
if self.exec_() == QDialog.Accepted:
|
if self.exec_() == QDialog.Accepted:
|
||||||
if self.kind in [NODE, MODULE, INTERFACE]:
|
if self.kind in [NODE, MODULE, INTERFACE]:
|
||||||
return [self.name.text(), self.get_value()]
|
return [self.name.text(), self.get_value()]
|
||||||
elif self.kind in [PARAMETER, PROPERTY, COMMENT]:
|
if self.kind in [PARAMETER, PROPERTY, COMMENT]:
|
||||||
return [self.get_value()]
|
return [self.get_value()]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ _orange = QBrush(QColor('#ffa500'))
|
|||||||
|
|
||||||
my_uipath = path.dirname(__file__)
|
my_uipath = path.dirname(__file__)
|
||||||
|
|
||||||
class MiniPlotCurve(object):
|
class MiniPlotCurve:
|
||||||
# placeholder for data
|
# placeholder for data
|
||||||
linecolor = _black
|
linecolor = _black
|
||||||
linewidth = 0 # set to 0 to disable lines
|
linewidth = 0 # set to 0 to disable lines
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
import json
|
import json
|
||||||
import pprint
|
import pprint
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
import mlzlog
|
||||||
|
|
||||||
from secop.datatypes import EnumType, StringType
|
from secop.datatypes import EnumType, StringType
|
||||||
from secop.errors import SECoPError
|
from secop.errors import SECoPError
|
||||||
@ -222,7 +223,6 @@ class ReadableWidget(QWidget):
|
|||||||
try:
|
try:
|
||||||
# if queried, we get the qualifiers as well, but don't want them
|
# if queried, we get the qualifiers as well, but don't want them
|
||||||
# here
|
# here
|
||||||
import mlzlog
|
|
||||||
mlzlog.getLogger('cached values').warn(
|
mlzlog.getLogger('cached values').warn(
|
||||||
'no cached value for %s:%s' % (self._module, pname))
|
'no cached value for %s:%s' % (self._module, pname))
|
||||||
val = self._node.getParameter(self._module, pname)[0]
|
val = self._node.getParameter(self._module, pname)[0]
|
||||||
|
@ -32,6 +32,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
import importlib
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
repodir = path.abspath(path.join(path.dirname(__file__), '..', '..'))
|
repodir = path.abspath(path.join(path.dirname(__file__), '..', '..'))
|
||||||
@ -51,7 +52,7 @@ CONFIG = {
|
|||||||
|
|
||||||
unset_value = object()
|
unset_value = object()
|
||||||
|
|
||||||
class lazy_property(object):
|
class lazy_property:
|
||||||
"""A property that calculates its value only once."""
|
"""A property that calculates its value only once."""
|
||||||
|
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
@ -89,7 +90,6 @@ def clamp(_min, value, _max):
|
|||||||
def get_class(spec):
|
def get_class(spec):
|
||||||
"""loads a class given by string in dotted notaion (as python would do)"""
|
"""loads a class given by string in dotted notaion (as python would do)"""
|
||||||
modname, classname = spec.rsplit('.', 1)
|
modname, classname = spec.rsplit('.', 1)
|
||||||
import importlib
|
|
||||||
if modname.startswith('secop'):
|
if modname.startswith('secop'):
|
||||||
module = importlib.import_module(modname)
|
module = importlib.import_module(modname)
|
||||||
else:
|
else:
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
__ALL__ = ['Enum']
|
__ALL__ = ['Enum']
|
||||||
|
|
||||||
|
|
||||||
class EnumMember(object):
|
class EnumMember:
|
||||||
"""represents one member of an Enum
|
"""represents one member of an Enum
|
||||||
|
|
||||||
has an int-type value and attributes 'name' and 'value'
|
has an int-type value and attributes 'name' and 'value'
|
||||||
@ -53,7 +53,7 @@ class EnumMember(object):
|
|||||||
return -1 # XXX:!
|
return -1 # XXX:!
|
||||||
if self.value < other:
|
if self.value < other:
|
||||||
return -1
|
return -1
|
||||||
elif self.value > other:
|
if self.value > other:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ class Enum(dict):
|
|||||||
elif isinstance(parent, dict):
|
elif isinstance(parent, dict):
|
||||||
for k, v in parent.items():
|
for k, v in parent.items():
|
||||||
add(self, k, v)
|
add(self, k, v)
|
||||||
elif parent != None:
|
elif parent is not None:
|
||||||
raise TypeError('parent (if given) MUST be a dict or an Enum!')
|
raise TypeError('parent (if given) MUST be a dict or an Enum!')
|
||||||
for k, v in kwds.items():
|
for k, v in kwds.items():
|
||||||
add(self, k, v)
|
add(self, k, v)
|
||||||
@ -286,7 +286,7 @@ class Enum(dict):
|
|||||||
raise TypeError('Enum %r can not be changed!' % self.name)
|
raise TypeError('Enum %r can not be changed!' % self.name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Enum %r (%d values)>' % (self.name, len(self)/2)
|
return '<Enum %r (%d values)>' % (self.name, len(self)//2)
|
||||||
|
|
||||||
def __call__(self, key):
|
def __call__(self, key):
|
||||||
return self[key]
|
return self[key]
|
||||||
|
@ -149,7 +149,7 @@ def format_args(args):
|
|||||||
return repr(args) # for floats/ints/...
|
return repr(args) # for floats/ints/...
|
||||||
|
|
||||||
|
|
||||||
class ArgsParser(object):
|
class ArgsParser:
|
||||||
"""returns a pythonic object from the input expression
|
"""returns a pythonic object from the input expression
|
||||||
|
|
||||||
grammar:
|
grammar:
|
||||||
@ -164,10 +164,8 @@ class ArgsParser(object):
|
|||||||
name = [A-Za-z_] [A-Za-z0-9_]*
|
name = [A-Za-z_] [A-Za-z0-9_]*
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DIGITS_CHARS = [c for c in '0123456789']
|
DIGITS_CHARS = '0123456789'
|
||||||
NAME_CHARS = [
|
NAME_CHARS = '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||||
c for c in '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
|
||||||
]
|
|
||||||
NAME_CHARS2 = NAME_CHARS + DIGITS_CHARS
|
NAME_CHARS2 = NAME_CHARS + DIGITS_CHARS
|
||||||
|
|
||||||
def __init__(self, string=''):
|
def __init__(self, string=''):
|
||||||
@ -276,7 +274,7 @@ class ArgsParser(object):
|
|||||||
|
|
||||||
def parse_record(self):
|
def parse_record(self):
|
||||||
"""record_expr = '(' (name '=' expr ',')* ')' """
|
"""record_expr = '(' (name '=' expr ',')* ')' """
|
||||||
if self.get != '(':
|
if self.get() != '(':
|
||||||
return None
|
return None
|
||||||
self.skip()
|
self.skip()
|
||||||
res = {}
|
res = {}
|
||||||
|
@ -30,11 +30,11 @@ from secop.errors import IsBusyError
|
|||||||
from secop.lib import mkthread
|
from secop.lib import mkthread
|
||||||
|
|
||||||
|
|
||||||
class Namespace(object):
|
class Namespace:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Step(object):
|
class Step:
|
||||||
|
|
||||||
def __init__(self, desc, waittime, func, *args, **kwds):
|
def __init__(self, desc, waittime, func, *args, **kwds):
|
||||||
self.desc = desc
|
self.desc = desc
|
||||||
@ -44,7 +44,7 @@ class Step(object):
|
|||||||
self.kwds = kwds
|
self.kwds = kwds
|
||||||
|
|
||||||
|
|
||||||
class SequencerMixin(object):
|
class SequencerMixin:
|
||||||
"""Mixin for worker classes that need to execute a sequence of actions,
|
"""Mixin for worker classes that need to execute a sequence of actions,
|
||||||
including waits, that exceeds the usual Tango timeout (about 3 seconds)
|
including waits, that exceeds the usual Tango timeout (about 3 seconds)
|
||||||
and should be executed asynchronously.
|
and should be executed asynchronously.
|
||||||
@ -129,11 +129,11 @@ class SequencerMixin(object):
|
|||||||
def read_status(self):
|
def read_status(self):
|
||||||
if self.seq_is_alive():
|
if self.seq_is_alive():
|
||||||
return self.Status.BUSY, 'moving: ' + self._seq_phase
|
return self.Status.BUSY, 'moving: ' + self._seq_phase
|
||||||
elif self._seq_error:
|
if self._seq_error:
|
||||||
if self._seq_fault_on_error:
|
if self._seq_fault_on_error:
|
||||||
return self.Status.ERROR, self._seq_error
|
return self.Status.ERROR, self._seq_error
|
||||||
return self.Status.WARN, self._seq_error
|
return self.Status.WARN, self._seq_error
|
||||||
elif self._seq_stopped:
|
if self._seq_stopped:
|
||||||
if self._seq_fault_on_stop:
|
if self._seq_fault_on_stop:
|
||||||
return self.Status.ERROR, self._seq_stopped
|
return self.Status.ERROR, self._seq_stopped
|
||||||
return self.Status.WARN, self._seq_stopped
|
return self.Status.WARN, self._seq_stopped
|
||||||
|
@ -45,12 +45,12 @@ class ModuleMeta(PropertyMeta):
|
|||||||
and wraps read_*/write_* methods
|
and wraps read_*/write_* methods
|
||||||
(so the dispatcher will get notfied of changed values)
|
(so the dispatcher will get notfied of changed values)
|
||||||
"""
|
"""
|
||||||
def __new__(mcs, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
commands = attrs.pop('commands', {})
|
commands = attrs.pop('commands', {})
|
||||||
parameters = attrs.pop('parameters', {})
|
parameters = attrs.pop('parameters', {})
|
||||||
overrides = attrs.pop('overrides', {})
|
overrides = attrs.pop('overrides', {})
|
||||||
|
|
||||||
newtype = type.__new__(mcs, name, bases, attrs)
|
newtype = type.__new__(cls, name, bases, attrs)
|
||||||
if '__constructed__' in attrs:
|
if '__constructed__' in attrs:
|
||||||
return newtype
|
return newtype
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ class Readable(Module):
|
|||||||
rfunc() # pylint: disable = not-callable
|
rfunc() # pylint: disable = not-callable
|
||||||
except Exception: # really all!
|
except Exception: # really all!
|
||||||
pass
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class Writable(Readable):
|
class Writable(Readable):
|
||||||
|
@ -30,7 +30,7 @@ from secop.errors import ProgrammingError
|
|||||||
from secop.properties import HasProperties, Property
|
from secop.properties import HasProperties, Property
|
||||||
|
|
||||||
|
|
||||||
class CountedObj(object):
|
class CountedObj:
|
||||||
ctr = [0]
|
ctr = [0]
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
cl = self.__class__.ctr
|
cl = self.__class__.ctr
|
||||||
@ -163,7 +163,7 @@ class Parameter(Accessible):
|
|||||||
del _set_unit_
|
del _set_unit_
|
||||||
|
|
||||||
|
|
||||||
class UnusedClass(object):
|
class UnusedClass:
|
||||||
# do not derive anything from this!
|
# do not derive anything from this!
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class Parameters(OrderedDict):
|
|||||||
return super(Parameters, self).__getitem__(self.exported.get(item, item))
|
return super(Parameters, self).__getitem__(self.exported.get(item, item))
|
||||||
|
|
||||||
|
|
||||||
class ParamValue(object):
|
class ParamValue:
|
||||||
__slots__ = ['value', 'timestamp']
|
__slots__ = ['value', 'timestamp']
|
||||||
def __init__(self, value, timestamp=0):
|
def __init__(self, value, timestamp=0):
|
||||||
self.value = value
|
self.value = value
|
||||||
@ -195,7 +195,6 @@ class ParamValue(object):
|
|||||||
|
|
||||||
class Commands(Parameters):
|
class Commands(Parameters):
|
||||||
"""class storage for Commands"""
|
"""class storage for Commands"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Override(CountedObj):
|
class Override(CountedObj):
|
||||||
@ -232,7 +231,6 @@ class Override(CountedObj):
|
|||||||
#props['ctr'] = self.ctr
|
#props['ctr'] = self.ctr
|
||||||
return type(obj)(ctr=self.ctr, **props)
|
return type(obj)(ctr=self.ctr, **props)
|
||||||
return type(obj)(**props)
|
return type(obj)(**props)
|
||||||
else:
|
|
||||||
raise ProgrammingError(
|
raise ProgrammingError(
|
||||||
u"Overrides can only be applied to Accessibles, %r is none!" %
|
u"Overrides can only be applied to Accessibles, %r is none!" %
|
||||||
obj)
|
obj)
|
||||||
|
@ -40,7 +40,7 @@ further convertions are done by the validator of the datatype....
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
class Parser(object):
|
class Parser:
|
||||||
# all parsing methods return (parsed value, remaining string)
|
# all parsing methods return (parsed value, remaining string)
|
||||||
# or (None, remaining_text) if parsing error
|
# or (None, remaining_text) if parsing error
|
||||||
|
|
||||||
@ -153,9 +153,9 @@ class Parser(object):
|
|||||||
return None, orgtext
|
return None, orgtext
|
||||||
if text[0] in '+-.0123456789':
|
if text[0] in '+-.0123456789':
|
||||||
return self.parse_number(orgtext)
|
return self.parse_number(orgtext)
|
||||||
elif text[0] == '{':
|
if text[0] == '{':
|
||||||
return self.parse_dict(orgtext)
|
return self.parse_dict(orgtext)
|
||||||
elif text[0] in '([<':
|
if text[0] in '([<':
|
||||||
return self.parse_tuple(orgtext)
|
return self.parse_tuple(orgtext)
|
||||||
return self.parse_string(orgtext)
|
return self.parse_string(orgtext)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ SLOW = 2
|
|||||||
REGULAR = 3
|
REGULAR = 3
|
||||||
DYNAMIC = 4
|
DYNAMIC = 4
|
||||||
|
|
||||||
class PollerBase(object):
|
class PollerBase:
|
||||||
|
|
||||||
startup_timeout = 30 # default timeout for startup
|
startup_timeout = 30 # default timeout for startup
|
||||||
name = 'unknown' # to be overridden in implementors __init__ method
|
name = 'unknown' # to be overridden in implementors __init__ method
|
||||||
@ -149,7 +149,7 @@ class Poller(PollerBase):
|
|||||||
raise ProgrammingError("module %s must have a pollinterval"
|
raise ProgrammingError("module %s must have a pollinterval"
|
||||||
% module.name)
|
% module.name)
|
||||||
if polltype == AUTO: # covers also pobj.poll == True
|
if polltype == AUTO: # covers also pobj.poll == True
|
||||||
if pname == 'value' or pname == 'status':
|
if pname in ('value', 'status'):
|
||||||
polltype = DYNAMIC
|
polltype = DYNAMIC
|
||||||
elif pobj.readonly:
|
elif pobj.readonly:
|
||||||
polltype = REGULAR
|
polltype = REGULAR
|
||||||
|
@ -29,7 +29,7 @@ from secop.errors import ProgrammingError, ConfigError
|
|||||||
|
|
||||||
|
|
||||||
# storage for 'properties of a property'
|
# storage for 'properties of a property'
|
||||||
class Property(object):
|
class Property:
|
||||||
'''base class holding info about a property
|
'''base class holding info about a property
|
||||||
|
|
||||||
properties are only sent to the ECS if export is True, or an extname is set
|
properties are only sent to the ECS if export is True, or an extname is set
|
||||||
@ -82,18 +82,18 @@ class PropertyMeta(type):
|
|||||||
joining the class's properties with those of base classes.
|
joining the class's properties with those of base classes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __new__(mcs, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
newtype = type.__new__(mcs, name, bases, attrs)
|
newtype = type.__new__(cls, name, bases, attrs)
|
||||||
if '__constructed__' in attrs:
|
if '__constructed__' in attrs:
|
||||||
return newtype
|
return newtype
|
||||||
|
|
||||||
newtype = mcs.__join_properties__(newtype, name, bases, attrs)
|
newtype = cls.__join_properties__(newtype, name, bases, attrs)
|
||||||
|
|
||||||
attrs['__constructed__'] = True
|
attrs['__constructed__'] = True
|
||||||
return newtype
|
return newtype
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __join_properties__(mcs, newtype, name, bases, attrs):
|
def __join_properties__(cls, newtype, name, bases, attrs):
|
||||||
# merge properties from all sub-classes
|
# merge properties from all sub-classes
|
||||||
properties = Properties()
|
properties = Properties()
|
||||||
for base in reversed(bases):
|
for base in reversed(bases):
|
||||||
@ -114,7 +114,7 @@ class PropertyMeta(type):
|
|||||||
return newtype
|
return newtype
|
||||||
|
|
||||||
|
|
||||||
class HasProperties(object, metaclass=PropertyMeta):
|
class HasProperties(metaclass=PropertyMeta):
|
||||||
properties = {}
|
properties = {}
|
||||||
|
|
||||||
def __init__(self, supercall_init=True):
|
def __init__(self, supercall_init=True):
|
||||||
|
@ -50,7 +50,7 @@ from secop.protocol.messages import COMMANDREPLY, DESCRIPTIONREPLY, \
|
|||||||
HEARTBEATREPLY, IDENTREPLY, IDENTREQUEST, READREPLY, WRITEREPLY
|
HEARTBEATREPLY, IDENTREPLY, IDENTREQUEST, READREPLY, WRITEREPLY
|
||||||
|
|
||||||
|
|
||||||
class Dispatcher(object):
|
class Dispatcher:
|
||||||
|
|
||||||
def __init__(self, name, logger, options, srv):
|
def __init__(self, name, logger, options, srv):
|
||||||
# to avoid errors, we want to eat all options here
|
# to avoid errors, we want to eat all options here
|
||||||
@ -145,7 +145,7 @@ class Dispatcher(object):
|
|||||||
def get_module(self, modulename):
|
def get_module(self, modulename):
|
||||||
if modulename in self._modules:
|
if modulename in self._modules:
|
||||||
return self._modules[modulename]
|
return self._modules[modulename]
|
||||||
elif modulename in list(self._modules.values()):
|
if modulename in list(self._modules.values()):
|
||||||
return modulename
|
return modulename
|
||||||
raise NoSuchModuleError('Module does not exist on this SEC-Node!')
|
raise NoSuchModuleError('Module does not exist on this SEC-Node!')
|
||||||
|
|
||||||
@ -296,7 +296,6 @@ class Dispatcher(object):
|
|||||||
|
|
||||||
if handler:
|
if handler:
|
||||||
return handler(conn, specifier, data)
|
return handler(conn, specifier, data)
|
||||||
else:
|
|
||||||
raise InternalError('unhandled message!')
|
raise InternalError('unhandled message!')
|
||||||
|
|
||||||
# now the (defined) handlers for the different requests
|
# now the (defined) handlers for the different requests
|
||||||
|
@ -40,7 +40,7 @@ except ImportError:
|
|||||||
import daemon.pidfile as pidlockfile
|
import daemon.pidfile as pidlockfile
|
||||||
|
|
||||||
|
|
||||||
class Server(object):
|
class Server:
|
||||||
# list allowed section prefixes
|
# list allowed section prefixes
|
||||||
# if mapped dict does not exist -> section need a 'class' option
|
# if mapped dict does not exist -> section need a 'class' option
|
||||||
# otherwise a 'type' option is evaluatet and the class from the mapping dict used
|
# otherwise a 'type' option is evaluatet and the class from the mapping dict used
|
||||||
|
@ -30,7 +30,7 @@ from secop.lib import mkthread
|
|||||||
from secop.modules import Drivable, Module, Parameter, Readable, Writable
|
from secop.modules import Drivable, Module, Parameter, Readable, Writable
|
||||||
|
|
||||||
|
|
||||||
class SimBase(object):
|
class SimBase:
|
||||||
def __init__(self, cfgdict):
|
def __init__(self, cfgdict):
|
||||||
# spice up parameters if requested by extra property
|
# spice up parameters if requested by extra property
|
||||||
# hint: us a comma-separated list if mor than one extra_param
|
# hint: us a comma-separated list if mor than one extra_param
|
||||||
|
@ -68,9 +68,8 @@ def get_version(abbrev=4):
|
|||||||
if git_version != release_version:
|
if git_version != release_version:
|
||||||
write_release_version(git_version)
|
write_release_version(git_version)
|
||||||
return git_version
|
return git_version
|
||||||
elif release_version:
|
if release_version:
|
||||||
return release_version
|
return release_version
|
||||||
else:
|
|
||||||
raise ValueError('Cannot find a version number - make sure that '
|
raise ValueError('Cannot find a version number - make sure that '
|
||||||
'git is installed or a RELEASE-VERSION file is '
|
'git is installed or a RELEASE-VERSION file is '
|
||||||
'present!')
|
'present!')
|
||||||
|
@ -155,11 +155,11 @@ class MagneticField(Drivable):
|
|||||||
if self._state == self._state.enum.idle:
|
if self._state == self._state.enum.idle:
|
||||||
return (PERSIST, 'at field') if self.value else \
|
return (PERSIST, 'at field') if self.value else \
|
||||||
(self.Status.IDLE, 'zero field')
|
(self.Status.IDLE, 'zero field')
|
||||||
elif self._state == self._state.enum.switch_on:
|
if self._state == self._state.enum.switch_on:
|
||||||
return (self.Status.PREPARE, self._state.name)
|
return (self.Status.PREPARE, self._state.name)
|
||||||
elif self._state == self._state.enum.switch_off:
|
if self._state == self._state.enum.switch_off:
|
||||||
return (self.Status.FINISH, self._state.name)
|
return (self.Status.FINISH, self._state.name)
|
||||||
elif self._state == self._state.enum.ramp:
|
if self._state == self._state.enum.ramp:
|
||||||
return (self.Status.RAMPING, self._state.name)
|
return (self.Status.RAMPING, self._state.name)
|
||||||
return (self.Status.ERROR, self._state.name)
|
return (self.Status.ERROR, self._state.name)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ from secop.modules import Drivable, Parameter, Readable
|
|||||||
try:
|
try:
|
||||||
from pvaccess import Channel # import EPIVSv4 functionallity, PV access
|
from pvaccess import Channel # import EPIVSv4 functionallity, PV access
|
||||||
except ImportError:
|
except ImportError:
|
||||||
class Channel(object):
|
class Channel:
|
||||||
|
|
||||||
def __init__(self, pv_name):
|
def __init__(self, pv_name):
|
||||||
self.pv_name = pv_name
|
self.pv_name = pv_name
|
||||||
@ -48,7 +48,7 @@ except ImportError:
|
|||||||
try:
|
try:
|
||||||
from epics import PV
|
from epics import PV
|
||||||
except ImportError:
|
except ImportError:
|
||||||
class PV(object):
|
class PV:
|
||||||
|
|
||||||
def __init__(self, pv_name):
|
def __init__(self, pv_name):
|
||||||
self.pv_name = pv_name
|
self.pv_name = pv_name
|
||||||
|
@ -116,7 +116,7 @@ class GarfieldMagnet(SequencerMixin, Drivable):
|
|||||||
if field == tryfield:
|
if field == tryfield:
|
||||||
self.log.debug('current for %g T is %g A', field, trycurr)
|
self.log.debug('current for %g T is %g A', field, trycurr)
|
||||||
return trycurr # Gotcha!
|
return trycurr # Gotcha!
|
||||||
elif field > tryfield:
|
if field > tryfield:
|
||||||
# retry upper interval
|
# retry upper interval
|
||||||
mincurr = trycurr
|
mincurr = trycurr
|
||||||
minfield = tryfield
|
minfield = tryfield
|
||||||
|
@ -6,7 +6,7 @@ import pytest
|
|||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def constants():
|
def constants():
|
||||||
# setup
|
# setup
|
||||||
class Constants(object):
|
class Constants:
|
||||||
ONE = 1
|
ONE = 1
|
||||||
TWO = 2
|
TWO = 2
|
||||||
c = Constants()
|
c = Constants()
|
||||||
|
@ -29,7 +29,7 @@ from secop.basic_validators import FloatProperty, PositiveFloatProperty, \
|
|||||||
NonNegativeIntProperty, BoolProperty, StringProperty, UnitProperty, \
|
NonNegativeIntProperty, BoolProperty, StringProperty, UnitProperty, \
|
||||||
FmtStrProperty, OneOfProperty, NoneOr, EnumProperty, TupleProperty
|
FmtStrProperty, OneOfProperty, NoneOr, EnumProperty, TupleProperty
|
||||||
|
|
||||||
class unprintable(object):
|
class unprintable:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ from secop.client.baseclient import Client
|
|||||||
# define Test-only connection object
|
# define Test-only connection object
|
||||||
|
|
||||||
|
|
||||||
class TestConnect(object):
|
class TestConnect:
|
||||||
callbacks = []
|
callbacks = []
|
||||||
|
|
||||||
def writeline(self, line):
|
def writeline(self, line):
|
||||||
|
@ -28,7 +28,7 @@ from secop.modules import Drivable
|
|||||||
from secop.poller import Poller, REGULAR, DYNAMIC, SLOW
|
from secop.poller import Poller, REGULAR, DYNAMIC, SLOW
|
||||||
Status = Drivable.Status
|
Status = Drivable.Status
|
||||||
|
|
||||||
class Time(object):
|
class Time:
|
||||||
STARTTIME = 1000 # artificial time zero
|
STARTTIME = 1000 # artificial time zero
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.reset()
|
self.reset()
|
||||||
@ -65,7 +65,7 @@ def patch_time(monkeypatch):
|
|||||||
monkeypatch.setattr(time, 'time', artime.time)
|
monkeypatch.setattr(time, 'time', artime.time)
|
||||||
|
|
||||||
|
|
||||||
class Event(object):
|
class Event:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.flag = False
|
self.flag = False
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class Event(object):
|
|||||||
return self.flag
|
return self.flag
|
||||||
|
|
||||||
|
|
||||||
class Parameter(object):
|
class Parameter:
|
||||||
def __init__(self, name, readonly, poll, polltype, interval):
|
def __init__(self, name, readonly, poll, polltype, interval):
|
||||||
self.poll = poll
|
self.poll = poll
|
||||||
self.polltype = polltype # used for check only
|
self.polltype = polltype # used for check only
|
||||||
@ -107,7 +107,7 @@ class Parameter(object):
|
|||||||
return 'Parameter(%s)' % ", ".join("%s=%r" % item for item in self.__dict__.items())
|
return 'Parameter(%s)' % ", ".join("%s=%r" % item for item in self.__dict__.items())
|
||||||
|
|
||||||
|
|
||||||
class Module(object):
|
class Module:
|
||||||
properties = {}
|
properties = {}
|
||||||
pollerClass = Poller
|
pollerClass = Poller
|
||||||
iodev = 'common_iodev'
|
iodev = 'common_iodev'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user