diff --git a/secop/client/__init__.py b/secop/client/__init__.py index 0805b31..8015472 100644 --- a/secop/client/__init__.py +++ b/secop/client/__init__.py @@ -27,6 +27,7 @@ import code class NameSpace(dict): + def __init__(self): dict.__init__(self) self.__const = set() @@ -63,6 +64,7 @@ from os import path class ClientConsole(object): + def __init__(self, cfgname, basepath): self.namespace = NameSpace() self.namespace.setconst('help', self.helpCmd) @@ -98,6 +100,7 @@ from secop.protocol.messages import * class TCPConnection(object): + def __init__(self, connect, port, encoding, framing, **kwds): self.log = mlzlog.log.getChild('connection', False) self.encoder = ENCODERS[encoding]() @@ -164,6 +167,7 @@ class TCPConnection(object): class Client(object): + def __init__(self, opts): self.log = mlzlog.log.getChild('client', True) self._cache = dict() diff --git a/secop/client/baseclient.py b/secop/client/baseclient.py index 7ace750..78add40 100644 --- a/secop/client/baseclient.py +++ b/secop/client/baseclient.py @@ -481,9 +481,9 @@ class Client(object): def syncCommunicate(self, *msg): res = self._communicate(*msg) try: - res = self.encode_message(*res) + res = self.encode_message(*res) except Exception: - res = str(res) + res = str(res) return res def ping(self, pingctr=[0]): diff --git a/secop/devices/core.py b/secop/devices/core.py index 3e7855f..1849973 100644 --- a/secop/devices/core.py +++ b/secop/devices/core.py @@ -46,6 +46,7 @@ EVENT_ONLY_ON_CHANGED_VALUES = False class PARAM(object): + def __init__(self, description, validator=float, @@ -76,10 +77,10 @@ class PARAM(object): def as_dict(self, static_only=False): # used for serialisation only res = dict( - description=self.description, - readonly=self.readonly, - validator=validator_to_str(self.validator), - ) + description=self.description, + readonly=self.readonly, + validator=validator_to_str(self.validator), + ) if self.unit: res['unit'] = self.unit if self.group: @@ -93,6 +94,7 @@ class PARAM(object): # storage for CMDs settings (description + call signature...) class CMD(object): + def __init__(self, description, arguments, result): # descriptive text for humans self.description = description @@ -117,6 +119,7 @@ class CMD(object): class DeviceMeta(type): + def __new__(mcs, name, bases, attrs): newtype = type.__new__(mcs, name, bases, attrs) if '__constructed__' in attrs: @@ -221,10 +224,10 @@ class Device(object): # static PROPERTIES, definitions in derived classes should overwrite earlier ones. # how to configure some stuff which makes sense to take from configfile??? PROPERTIES = { - 'group' : None, # some Modules may be grouped together - 'meaning' : None, # XXX: ??? - 'priority' : None, # XXX: ??? - 'visibility' : None, # XXX: ???? + 'group': None, # some Modules may be grouped together + 'meaning': None, # XXX: ??? + 'priority': None, # XXX: ??? + 'visibility': None, # XXX: ???? # what else? } # PARAMS and CMDS are auto-merged upon subclassing @@ -251,7 +254,8 @@ class Device(object): self.PARAMS = params # check and apply properties specified in cfgdict - # moduleproperties are to be specified as '.=' + # moduleproperties are to be specified as + # '.=' for k, v in cfgdict.items(): if k[0] == '.': if k[1:] in self.PROPERTIES: @@ -262,17 +266,17 @@ class Device(object): myclassname = '%s.%s' % (mycls.__module__, mycls.__name__) self.PROPERTIES['implementation'] = myclassname self.PROPERTIES['interfaces'] = [b.__name__ for b in mycls.__mro__ - if b.__module__.startswith('secop.devices.core')] + if b.__module__.startswith('secop.devices.core')] self.PROPERTIES['interface'] = self.PROPERTIES['interfaces'][0] # remove unset (default) module properties - for k,v in self.PROPERTIES.items(): + for k, v in self.PROPERTIES.items(): if v == None: del self.PROPERTIES[k] # check and apply parameter_properties # specified as '. = ' - for k,v in cfgdict.items()[:]: + for k, v in cfgdict.items()[:]: if '.' in k[1:]: paramname, propname = k.split('.', 1) if paramname in self.PARAMS: @@ -338,15 +342,15 @@ class Readable(Device): 'pollinterval': PARAM('sleeptime between polls', default=5, readonly=False, validator=floatrange(0.1, 120), ), 'status': PARAM('current status of the device', default=(status.OK, ''), - validator=vector( - enum(**{ - 'IDLE': status.OK, - 'BUSY': status.BUSY, - 'WARN': status.WARN, - 'UNSTABLE': status.UNSTABLE, - 'ERROR': status.ERROR, - 'UNKNOWN': status.UNKNOWN - }), str), + validator=vector( + enum(**{ + 'IDLE': status.OK, + 'BUSY': status.BUSY, + 'WARN': status.WARN, + 'UNSTABLE': status.UNSTABLE, + 'ERROR': status.ERROR, + 'UNKNOWN': status.UNKNOWN + }), str), readonly=True), } @@ -374,7 +378,7 @@ class Driveable(Readable): """ PARAMS = { 'target': PARAM('target value of the device', default=0., readonly=False, - ), + ), } # XXX: CMDS ???? auto deriving working well enough? diff --git a/secop/devices/cryo.py b/secop/devices/cryo.py index a7f8948..caf2c37 100644 --- a/secop/devices/cryo.py +++ b/secop/devices/cryo.py @@ -30,9 +30,11 @@ from secop.protocol import status from secop.validators import floatrange, positive, enum, nonnegative, vector from secop.lib import clamp, mkthread + class CryoBase(Driveable): pass + class Cryostat(CryoBase): """simulated cryostat with: @@ -44,22 +46,22 @@ class Cryostat(CryoBase): jitter=PARAM("amount of random noise on readout values", validator=floatrange(0, 1), unit="K", default=0.1, readonly=False, export=False, - ), + ), T_start=PARAM("starting temperature for simulation", validator=positive, default=10, export=False, - ), + ), looptime=PARAM("timestep for simulation", validator=floatrange(0.01, 10), unit="s", default=1, readonly=False, export=False, - ), + ), ramp=PARAM("ramping speed of the setpoint", validator=floatrange(0, 1e3), unit="K/min", default=1, readonly=False, - ), + ), setpoint=PARAM("current setpoint during ramping else target", validator=float, default=1, unit='K', - ), + ), maxpower=PARAM("Maximum heater power", validator=nonnegative, default=1, unit="W", readonly=False, @@ -76,34 +78,35 @@ class Cryostat(CryoBase): target=PARAM("target temperature", validator=nonnegative, default=0, unit="K", readonly=False, - ), + ), value=PARAM("regulation temperature", validator=nonnegative, default=0, unit="K", - ), + ), pid=PARAM("regulation coefficients", - validator=vector(nonnegative, floatrange(0, 100), floatrange(0, 100)), + validator=vector(nonnegative, floatrange( + 0, 100), floatrange(0, 100)), default=(40, 10, 2), readonly=False, group='pid', - ), + ), p=PARAM("regulation coefficient 'p'", validator=nonnegative, default=40, unit="%/K", readonly=False, group='pid', - ), + ), i=PARAM("regulation coefficient 'i'", validator=floatrange(0, 100), default=10, readonly=False, group='pid', - ), + ), d=PARAM("regulation coefficient 'd'", validator=floatrange(0, 100), default=2, readonly=False, group='pid', - ), + ), mode=PARAM("mode of regulation", validator=enum('ramp', 'pid', 'openloop'), default='ramp', readonly=False, - ), + ), pollinterval=PARAM("polling interval", validator=positive, default=5, - ), + ), tolerance=PARAM("temperature range for stability checking", validator=floatrange(0, 100), default=0.1, unit='K', readonly=False, diff --git a/secop/devices/demo.py b/secop/devices/demo.py index bb1a184..ae433b5 100644 --- a/secop/devices/demo.py +++ b/secop/devices/demo.py @@ -35,19 +35,19 @@ class Switch(Driveable): PARAMS = { 'value': PARAM('current state (on or off)', validator=enum(on=1, off=0), default=0, - ), + ), 'target': PARAM('wanted state (on or off)', validator=enum(on=1, off=0), default=0, readonly=False, - ), + ), 'switch_on_time': PARAM('seconds to wait after activating the switch', validator=floatrange(0, 60), unit='s', default=10, export=False, - ), + ), 'switch_off_time': PARAM('cool-down time in seconds', validator=floatrange(0, 60), unit='s', default=10, export=False, - ), + ), } def init(self): @@ -100,22 +100,22 @@ class MagneticField(Driveable): PARAMS = { 'value': PARAM('current field in T', unit='T', validator=floatrange(-15, 15), default=0, - ), + ), 'target': PARAM('target field in T', unit='T', validator=floatrange(-15, 15), default=0, readonly=False, - ), + ), 'ramp': PARAM('ramping speed', unit='T/min', validator=floatrange(0, 1), default=0.1, readonly=False, - ), + ), 'mode': PARAM('what to do after changing field', default=1, validator=enum(persistent=1, hold=0), readonly=False, - ), + ), 'heatswitch': PARAM('name of heat switch device', validator=str, export=False, - ), + ), } def init(self): @@ -184,10 +184,10 @@ class CoilTemp(Readable): PARAMS = { 'value': PARAM('Coil temperatur', unit='K', validator=float, default=0, - ), + ), 'sensor': PARAM("Sensor number or calibration id", validator=str, readonly=True, - ), + ), } def read_value(self, maxage=0): @@ -200,14 +200,14 @@ class SampleTemp(Driveable): PARAMS = { 'value': PARAM('Sample temperature', unit='K', validator=float, default=10, - ), + ), 'sensor': PARAM("Sensor number or calibration id", validator=str, readonly=True, - ), + ), 'ramp': PARAM('moving speed in K/min', validator=floatrange(0, 100), unit='K/min', default=0.1, readonly=False, - ), + ), } def init(self): @@ -244,16 +244,16 @@ class Label(Readable): PARAMS = { 'system': PARAM("Name of the magnet system", validator=str, export=False, - ), + ), 'subdev_mf': PARAM("name of subdevice for magnet status", validator=str, export=False, - ), + ), 'subdev_ts': PARAM("name of subdevice for sample temp", validator=str, export=False, - ), + ), 'value': PARAM("final value of label string", validator=str, - ), + ), } def read_value(self, maxage=0): @@ -303,5 +303,5 @@ class ValidatorTest(Readable): validator=intrange(2, 9), readonly=False, default=4), 'floatrange': PARAM('floatrange', validator=floatrange(-1, 1), readonly=False, default=0, - ), + ), } diff --git a/secop/devices/epics.py b/secop/devices/epics.py index 188a1ca..9578034 100644 --- a/secop/devices/epics.py +++ b/secop/devices/epics.py @@ -28,16 +28,20 @@ from secop.devices.core import Readable, Device, Driveable, PARAM from secop.protocol import status try: - from pvaccess import Channel #import EPIVSv4 functionallity, PV access + from pvaccess import Channel # import EPIVSv4 functionallity, PV access except ImportError: class Channel(object): + def __init__(self, pv_name): self.pv_name = pv_name self.value = 0.0 + def get(self): return self + def getDouble(self): return self.value + def put(self, value): try: self.value = value @@ -48,10 +52,12 @@ try: from epics import PV except ImportError: class PV(object): + def __init__(self, pv_name): self.pv_name = pv_name self.value = 0.0 + class EpicsReadable(Readable): """EpicsDriveable handles a Driveable interfacing to EPICS v4""" # Commmon PARAMS for all EPICS devices @@ -64,16 +70,17 @@ class EpicsReadable(Readable): 'value_pv': PARAM('EPICS pv_name of value', validator=str, default="unset", export=False), 'status_pv': PARAM('EPICS pv_name of status', validator=str, - default="unset", export=False), + default="unset", export=False), } # Generic read and write functions def _read_pv(self, pv_name): if self.epics_version == 'v4': pv_channel = Channel(pv_name) - # TODO: cannot handle read of string (is there a .getText() or .getString() ?) + # TODO: cannot handle read of string (is there a .getText() or + # .getString() ?) return_value = pv_channel.get().getDouble() - else: # Not EPICS v4 + else: # Not EPICS v4 # TODO: fix this, it does not work pv = PV(pv_name + ".VAL") return_value = pv.value @@ -91,11 +98,10 @@ class EpicsReadable(Readable): if self.epics_version == 'v4': pv_channel = Channel(pv_name) pv_channel.put(write_value) - else: # Not EPICS v4 + else: # Not EPICS v4 pv = PV(pv_name + ".VAL") pv.value = write_value - def read_value(self, maxage=0): return self._read_pv(self.value_pv) @@ -109,7 +115,6 @@ class EpicsReadable(Readable): return (status.OK, 'no pv set') - class EpicsDriveable(Driveable): """EpicsDriveable handles a Driveable interfacing to EPICS v4""" # Commmon PARAMS for all EPICS devices @@ -126,16 +131,17 @@ class EpicsDriveable(Driveable): 'value_pv': PARAM('EPICS pv_name of value', validator=str, default="unset", export=False), 'status_pv': PARAM('EPICS pv_name of status', validator=str, - default="unset", export=False), + default="unset", export=False), } # Generic read and write functions def _read_pv(self, pv_name): if self.epics_version == 'v4': pv_channel = Channel(pv_name) - # TODO: cannot handle read of string (is there a .getText() or .getString() ?) + # TODO: cannot handle read of string (is there a .getText() or + # .getString() ?) return_value = pv_channel.get().getDouble() - else: # Not EPICS v4 + else: # Not EPICS v4 # TODO: fix this, it does not work pv = PV(pv_name + ".VAL") return_value = pv.value @@ -153,7 +159,7 @@ class EpicsDriveable(Driveable): if self.epics_version == 'v4': pv_channel = Channel(pv_name) pv_channel.put(write_value) - else: # Not EPICS v4 + else: # Not EPICS v4 pv = PV(pv_name + ".VAL") pv.value = write_value @@ -177,9 +183,11 @@ class EpicsDriveable(Driveable): (status.BUSY, 'Moving') - """Temperature control loop""" -# should also derive from secop.core.temperaturecontroller, once its features are agreed upon +# should also derive from secop.core.temperaturecontroller, once its +# features are agreed upon + + class EpicsTempCtrl(EpicsDriveable): PARAMS = { @@ -187,7 +195,7 @@ class EpicsTempCtrl(EpicsDriveable): 'heaterrange': PARAM('Heater range', validator=str, default='Off', readonly=False,), 'tolerance': PARAM('allowed deviation between value and target', - validator=floatrange(1e-6,1e6), default=0.1, + validator=floatrange(1e-6, 1e6), default=0.1, readonly=False,), # 'private' parameters: not remotely accessible 'heaterrange_pv': PARAM('EPICS pv_name of heater range', @@ -209,14 +217,13 @@ class EpicsTempCtrl(EpicsDriveable): def read_status(self, maxage=0): # XXX: comparison may need to collect a history to detect oscillations at_target = abs(self.read_value(maxage) - self.read_target(maxage)) \ - <= self.tolerance + <= self.tolerance return (status.OK, 'at Target') if at_target else (status.BUSY, 'Moving') # TODO: add support for strings over epics pv - #def read_heaterrange(self, maxage=0): + # def read_heaterrange(self, maxage=0): # return self._read_pv(self.heaterrange_pv) # TODO: add support for strings over epics pv - #def write_heaterrange(self, range_value): + # def write_heaterrange(self, range_value): # self._write_pv(self.heaterrange_pv, range_value) - diff --git a/secop/devices/test.py b/secop/devices/test.py index c9f8561..1437d01 100644 --- a/secop/devices/test.py +++ b/secop/devices/test.py @@ -46,7 +46,7 @@ class Heater(Driveable): PARAMS = { 'maxheaterpower': PARAM('maximum allowed heater power', validator=floatrange(0, 100), unit='W', - ), + ), } def read_value(self, maxage=0): @@ -65,10 +65,10 @@ class Temp(Driveable): PARAMS = { 'sensor': PARAM("Sensor number or calibration id", validator=str, readonly=True, - ), + ), 'target': PARAM("Target temperature", default=300.0, validator=positive, readonly=False, unit='K', - ), + ), } def read_value(self, maxage=0): diff --git a/secop/gui/mainwindow.py b/secop/gui/mainwindow.py index 424075d..16807af 100644 --- a/secop/gui/mainwindow.py +++ b/secop/gui/mainwindow.py @@ -37,6 +37,7 @@ ITEM_TYPE_MODULE = QTreeWidgetItem.UserType + 2 ITEM_TYPE_PARAMETER = QTreeWidgetItem.UserType + 3 + class QSECNode(SECNode, QObject): newData = pyqtSignal(str, str, object) # module, parameter, data @@ -63,6 +64,7 @@ class QSECNode(SECNode, QObject): class MainWindow(QMainWindow): + def __init__(self, parent=None): super(MainWindow, self).__init__(parent) diff --git a/secop/gui/modulectrl.py b/secop/gui/modulectrl.py index 525d6db..c35cc1d 100644 --- a/secop/gui/modulectrl.py +++ b/secop/gui/modulectrl.py @@ -56,6 +56,7 @@ class ParameterButtons(QWidget): class ModuleCtrl(QWidget): + def __init__(self, node, module, parent=None): super(ModuleCtrl, self).__init__(parent) loadUi(self, 'modulectrl.ui') diff --git a/secop/gui/nodectrl.py b/secop/gui/nodectrl.py index 22c32fe..fb4e8d0 100644 --- a/secop/gui/nodectrl.py +++ b/secop/gui/nodectrl.py @@ -32,6 +32,7 @@ from secop.protocol.errors import SECOPError class NodeCtrl(QWidget): + def __init__(self, node, parent=None): super(NodeCtrl, self).__init__(parent) loadUi(self, 'nodectrl.ui') diff --git a/secop/gui/paramview.py b/secop/gui/paramview.py index 6db8df8..9680691 100644 --- a/secop/gui/paramview.py +++ b/secop/gui/paramview.py @@ -29,6 +29,7 @@ from secop.validators import validator_to_str class ParameterView(QWidget): + def __init__(self, node, module, parameter, parent=None): super(ParameterView, self).__init__(parent) loadUi(self, 'paramview.ui') diff --git a/secop/lib/parsing.py b/secop/lib/parsing.py index 3b257cc..f2f03a8 100644 --- a/secop/lib/parsing.py +++ b/secop/lib/parsing.py @@ -80,6 +80,7 @@ def format_time(timestamp=None): class Timezone(tzinfo): + def __init__(self, offset, name='unknown timezone'): self.offset = offset self.name = name diff --git a/secop/protocol/dispatcher.py b/secop/protocol/dispatcher.py index b6ed582..b7fbd8b 100644 --- a/secop/protocol/dispatcher.py +++ b/secop/protocol/dispatcher.py @@ -46,6 +46,7 @@ from secop.lib.parsing import format_time class Dispatcher(object): + def __init__(self, logger, options): self.equipment_id = options.pop('equipment_id') self.log = logger @@ -213,7 +214,7 @@ class Dispatcher(object): dd = { 'parameters': self.list_module_params(modulename, only_static=True), 'commands': self.list_module_cmds(modulename), - 'properties' : module.PROPERTIES, + 'properties': module.PROPERTIES, } result['modules'][modulename] = dd result['equipment_id'] = self.equipment_id diff --git a/secop/protocol/encoding/demo_v2.py b/secop/protocol/encoding/demo_v2.py index b7d7af1..a0b90fd 100644 --- a/secop/protocol/encoding/demo_v2.py +++ b/secop/protocol/encoding/demo_v2.py @@ -36,6 +36,7 @@ DEMO_RE = re.compile( class DemoEncoder(MessageEncoder): + def decode(sef, encoded): # match [!][*|devicename][: *|paramname [: *|propname]] [=value] match = DEMO_RE.match(encoded) diff --git a/secop/protocol/encoding/demo_v3.py b/secop/protocol/encoding/demo_v3.py index 5e373e2..a2899eb 100644 --- a/secop/protocol/encoding/demo_v3.py +++ b/secop/protocol/encoding/demo_v3.py @@ -92,6 +92,7 @@ DEMO_RE_OTHER = re.compile( class DemoEncoder(MessageEncoder): + def __init__(self, *args, **kwds): MessageEncoder.__init__(self, *args, **kwds) self.result = [] # for decoding @@ -321,6 +322,7 @@ DEMO_RE_MZ = re.compile( class DemoEncoder_MZ(MessageEncoder): + def decode(sef, encoded): m = DEMO_RE_MZ.match(encoded) if m: diff --git a/secop/protocol/encoding/demo_v4.py b/secop/protocol/encoding/demo_v4.py index 5f38772..db1ced3 100644 --- a/secop/protocol/encoding/demo_v4.py +++ b/secop/protocol/encoding/demo_v4.py @@ -135,15 +135,18 @@ class DemoEncoder(MessageEncoder): encode_cmd_result, ), WriteRequest: ( WRITEREQUEST, - lambda msg: "%s:%s" % (msg.module, msg.parameter) if msg.parameter else msg.module, + lambda msg: "%s:%s" % ( + msg.module, msg.parameter) if msg.parameter else msg.module, 'value', ), WriteReply: ( WRITEREPLY, - lambda msg: "%s:%s" % (msg.module, msg.parameter) if msg.parameter else msg.module, + lambda msg: "%s:%s" % ( + msg.module, msg.parameter) if msg.parameter else msg.module, 'value', ), PollRequest: ( TRIGGERREQUEST, - lambda msg: "%s:%s" % (msg.module, msg.parameter) if msg.parameter else msg.module, + lambda msg: "%s:%s" % ( + msg.module, msg.parameter) if msg.parameter else msg.module, ), HeartbeatRequest: ( HEARTBEATREQUEST, @@ -158,7 +161,8 @@ class DemoEncoder(MessageEncoder): encode_error_msg, ), Value: ( EVENT, - lambda msg: "%s:%s" % (msg.module, msg.parameter or (msg.command + '()')) if msg.parameter or msg.command else msg.module, + lambda msg: "%s:%s" % (msg.module, msg.parameter or ( + msg.command + '()')) if msg.parameter or msg.command else msg.module, encode_value_data, ), } DECODEMAP = { diff --git a/secop/protocol/encoding/pickle.py b/secop/protocol/encoding/pickle.py index 9c66e27..351e093 100644 --- a/secop/protocol/encoding/pickle.py +++ b/secop/protocol/encoding/pickle.py @@ -35,6 +35,7 @@ except ImportError: class PickleEncoder(MessageEncoder): + def encode(self, messageobj): """msg object -> transport layer message""" return pickle.dumps(messageobj) diff --git a/secop/protocol/encoding/simplecomm.py b/secop/protocol/encoding/simplecomm.py index 51ddbe2..6be901c 100644 --- a/secop/protocol/encoding/simplecomm.py +++ b/secop/protocol/encoding/simplecomm.py @@ -37,6 +37,7 @@ SCPMESSAGE = re.compile( class SCPEncoder(MessageEncoder): + def encode(self, msg): """msg object -> transport layer message""" # fun for Humans diff --git a/secop/protocol/encoding/text.py b/secop/protocol/encoding/text.py index c5e9d4a..41b4647 100644 --- a/secop/protocol/encoding/text.py +++ b/secop/protocol/encoding/text.py @@ -30,6 +30,7 @@ from secop.lib.parsing import * class TextEncoder(MessageEncoder): + def __init__(self): # build safe namespace ns = dict() diff --git a/secop/protocol/errors.py b/secop/protocol/errors.py index 2d4accc..172181e 100644 --- a/secop/protocol/errors.py +++ b/secop/protocol/errors.py @@ -23,6 +23,7 @@ class SECOPError(RuntimeError): + def __init__(self, *args, **kwds): self.args = args for k, v in kwds.items(): diff --git a/secop/protocol/interface/tcp.py b/secop/protocol/interface/tcp.py index 72f189e..2281dbd 100644 --- a/secop/protocol/interface/tcp.py +++ b/secop/protocol/interface/tcp.py @@ -35,6 +35,7 @@ from secop.protocol.messages import HelpMessage class TCPRequestHandler(SocketServer.BaseRequestHandler): + def setup(self): self.log = self.server.log self._queue = collections.deque(maxlen=100) diff --git a/secop/protocol/messages.py b/secop/protocol/messages.py index 666483a..d9e52c8 100644 --- a/secop/protocol/messages.py +++ b/secop/protocol/messages.py @@ -50,6 +50,7 @@ class Message(object): class Value(object): + def __init__(self, module, parameter=None, diff --git a/secop/protocol/messages_old.py b/secop/protocol/messages_old.py index 277fb37..3f8506c 100644 --- a/secop/protocol/messages_old.py +++ b/secop/protocol/messages_old.py @@ -95,6 +95,7 @@ class Message(object): class Value(object): + def __init__(self, value=Ellipsis, qualifiers=None, **kwds): self.dev = '' self.param = '' @@ -166,6 +167,7 @@ class HelpMessage(Message): class NoSuchDeviceError(ErrorMessage): + def __init__(self, *devs): ErrorMessage.__init__( self, @@ -175,6 +177,7 @@ class NoSuchDeviceError(ErrorMessage): class NoSuchParamError(ErrorMessage): + def __init__(self, dev, *params): ErrorMessage.__init__( self, @@ -185,6 +188,7 @@ class NoSuchParamError(ErrorMessage): class ParamReadonlyError(ErrorMessage): + def __init__(self, dev, *params): ErrorMessage.__init__( self, @@ -196,6 +200,7 @@ class ParamReadonlyError(ErrorMessage): class InvalidParamValueError(ErrorMessage): + def __init__(self, dev, param, value, e): ErrorMessage.__init__( self, @@ -207,6 +212,7 @@ class InvalidParamValueError(ErrorMessage): class InternalError(ErrorMessage): + def __init__(self, err, **kwds): ErrorMessage.__init__( self, errorstring=str(err), errortype='InternalError', **kwds) @@ -217,7 +223,7 @@ MESSAGE = dict((cls.MSGTYPE, cls) HelpMessage, ErrorMessage, EventMessage, TriggerMessage, UnsubscribeMessage, SubscribeMessage, PollMessage, CommandMessage, WriteMessage, ReadMessage, ListMessage - ]) +]) if __name__ == '__main__': print("Minimal testing of messages....") diff --git a/secop/server.py b/secop/server.py index 40e48df..08ffbed 100644 --- a/secop/server.py +++ b/secop/server.py @@ -39,6 +39,7 @@ from secop.errors import ConfigError class Server(object): + def __init__(self, name, workdir, parentLogger=None): self._name = name self._workdir = workdir diff --git a/secop/validators.py b/secop/validators.py index c0939bd..d847822 100644 --- a/secop/validators.py +++ b/secop/validators.py @@ -200,6 +200,7 @@ class oneof(Validator): class enum(Validator): + def __init__(self, *args, **kwds): self.mapping = {} # use given kwds directly