fix issues raising pylint warnings
+ small bug fixes Change-Id: Ib63bf13ad06446d3ec3b8cd0b16f9426cef9e3f4
This commit is contained in:
parent
039ece9549
commit
d9cc85c1df
@ -517,7 +517,7 @@ class SecopClient(ProxyClient):
|
|||||||
raise ConnectionError('connection closed before reply')
|
raise ConnectionError('connection closed before reply')
|
||||||
action, _, data = entry[2] # pylint: disable=unpacking-non-sequence
|
action, _, data = entry[2] # pylint: disable=unpacking-non-sequence
|
||||||
if action.startswith(ERRORPREFIX):
|
if action.startswith(ERRORPREFIX):
|
||||||
errcls = self.error_map(data[0] + "Error")
|
errcls = self.error_map(data[0])
|
||||||
raise errcls(data[1])
|
raise errcls(data[1])
|
||||||
return entry[2] # reply
|
return entry[2] # reply
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ class FloatRange(DataType):
|
|||||||
try:
|
try:
|
||||||
value = float(value)
|
value = float(value)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise BadValueError('Can not __call__ %r to float' % value)
|
raise BadValueError('Can not convert %r to float' % value)
|
||||||
# map +/-infty to +/-max possible number
|
# map +/-infty to +/-max possible number
|
||||||
value = clamp(-sys.float_info.max, value, sys.float_info.max)
|
value = clamp(-sys.float_info.max, value, sys.float_info.max)
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ EXCEPTIONS = dict(
|
|||||||
NoSuchCommand=NoSuchCommandError,
|
NoSuchCommand=NoSuchCommandError,
|
||||||
CommandFailed=CommandFailedError,
|
CommandFailed=CommandFailedError,
|
||||||
CommandRunning=CommandRunningError,
|
CommandRunning=CommandRunningError,
|
||||||
Readonly=ReadOnlyError,
|
ReadOnly=ReadOnlyError,
|
||||||
BadValue=BadValueError,
|
BadValue=BadValueError,
|
||||||
CommunicationFailed=CommunicationFailedError,
|
CommunicationFailed=CommunicationFailedError,
|
||||||
HardwareError=HardwareError,
|
HardwareError=HardwareError,
|
||||||
|
@ -149,9 +149,6 @@ class Parameter(Accessible):
|
|||||||
handler = Property(
|
handler = Property(
|
||||||
'[internal] overload the standard read and write functions', ValueType(),
|
'[internal] overload the standard read and write functions', ValueType(),
|
||||||
export=False, default=None, settable=False)
|
export=False, default=None, settable=False)
|
||||||
persistent = Property(
|
|
||||||
'[internal] persistent setting', BoolType(),
|
|
||||||
export=False, default=False)
|
|
||||||
initwrite = Property(
|
initwrite = Property(
|
||||||
'''[internal] write this parameter on initialization
|
'''[internal] write this parameter on initialization
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class HasProperties(HasDescriptors):
|
|||||||
propertyValues = None
|
propertyValues = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(HasProperties, self).__init__()
|
super().__init__()
|
||||||
# store property values in the instance, keep descriptors on the class
|
# store property values in the instance, keep descriptors on the class
|
||||||
self.propertyValues = {}
|
self.propertyValues = {}
|
||||||
# pre-init
|
# pre-init
|
||||||
@ -168,9 +168,9 @@ class HasProperties(HasDescriptors):
|
|||||||
if pn in getattr(base, 'propertyDict', {}):
|
if pn in getattr(base, 'propertyDict', {}):
|
||||||
if callable(value):
|
if callable(value):
|
||||||
raise ProgrammingError('method %s.%s collides with property of %s' %
|
raise ProgrammingError('method %s.%s collides with property of %s' %
|
||||||
(cls.__name__, pn, base.__name__))
|
(cls.__name__, pn, base.__name__)) from None
|
||||||
raise ProgrammingError('can not set property %s.%s to %r' %
|
raise ProgrammingError('can not set property %s.%s to %r' %
|
||||||
(cls.__name__, pn, value))
|
(cls.__name__, pn, value)) from None
|
||||||
cls.propertyDict[pn] = po
|
cls.propertyDict[pn] = po
|
||||||
|
|
||||||
def checkProperties(self):
|
def checkProperties(self):
|
||||||
@ -181,7 +181,7 @@ class HasProperties(HasDescriptors):
|
|||||||
self.propertyValues[pn] = po.datatype(self.propertyValues[pn])
|
self.propertyValues[pn] = po.datatype(self.propertyValues[pn])
|
||||||
except (KeyError, BadValueError):
|
except (KeyError, BadValueError):
|
||||||
name = getattr(self, 'name', self.__class__.__name__)
|
name = getattr(self, 'name', self.__class__.__name__)
|
||||||
raise ConfigError('%s.%s needs a value of type %r!' % (name, pn, po.datatype))
|
raise ConfigError('%s.%s needs a value of type %r!' % (name, pn, po.datatype)) from None
|
||||||
for pn, po in self.propertyDict.items():
|
for pn, po in self.propertyDict.items():
|
||||||
if pn.startswith('min'):
|
if pn.startswith('min'):
|
||||||
maxname = 'max' + pn[3:]
|
maxname = 'max' + pn[3:]
|
||||||
|
@ -26,6 +26,7 @@ import socketserver
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import errno
|
||||||
|
|
||||||
from secop.datatypes import BoolType, StringType
|
from secop.datatypes import BoolType, StringType
|
||||||
from secop.errors import SECoPError
|
from secop.errors import SECoPError
|
||||||
@ -192,9 +193,9 @@ class TCPServer(socketserver.ThreadingTCPServer):
|
|||||||
self, ('0.0.0.0', port), TCPRequestHandler, bind_and_activate=True)
|
self, ('0.0.0.0', port), TCPRequestHandler, bind_and_activate=True)
|
||||||
break
|
break
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.args[0] == 98: # address already in use
|
if e.args[0] == errno.EADDRINUSE: # address already in use
|
||||||
# this may happen despite of allow_reuse_address
|
# this may happen despite of allow_reuse_address
|
||||||
time.sleep(0.3 * (1 << ntry))
|
time.sleep(0.3 * (1 << ntry)) # max accumulated sleep time: 0.3 * 31 = 9.3 sec
|
||||||
else:
|
else:
|
||||||
self.log.error('could not initialize TCP Server: %r' % e)
|
self.log.error('could not initialize TCP Server: %r' % e)
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user