raise ProtcolError when specifier is missing
- fixed this for 'read', 'change' and 'do' message + fix an error in frappy.client.SecopClient closing the connection when the identifier is None fixes: #4672 Change-Id: Iaba0f9ed86b6eb6ef7588403ba640ded552dded6
This commit is contained in:
@ -318,12 +318,12 @@ class SecopClient(ProxyClient):
|
||||
ident = None
|
||||
if action in UPDATE_MESSAGES:
|
||||
module_param = self.internal.get(ident, None)
|
||||
if module_param is None and ':' not in ident:
|
||||
if module_param is None and ':' not in (ident or ''):
|
||||
# allow missing ':value'/':target'
|
||||
if action == WRITEREPLY:
|
||||
module_param = self.internal.get(ident + ':target', None)
|
||||
module_param = self.internal.get('%s:target' % ident, None)
|
||||
else:
|
||||
module_param = self.internal.get(ident + ':value', None)
|
||||
module_param = self.internal.get('%s:value' % ident, None)
|
||||
if module_param is not None:
|
||||
if action.startswith(ERRORPREFIX):
|
||||
timestamp = data[2].get('t', None)
|
||||
|
@ -318,6 +318,8 @@ class Dispatcher:
|
||||
def handle_read(self, conn, specifier, data):
|
||||
if data:
|
||||
raise ProtocolError('read requests don\'t take data!')
|
||||
if not specifier:
|
||||
raise ProtocolError('read requests need a specifier!')
|
||||
modulename, pname = specifier, 'value'
|
||||
if ':' in specifier:
|
||||
modulename, pname = specifier.split(':', 1)
|
||||
@ -325,12 +327,16 @@ class Dispatcher:
|
||||
return (READREPLY, specifier, list(self._getParameterValue(modulename, pname)))
|
||||
|
||||
def handle_change(self, conn, specifier, data):
|
||||
if not specifier:
|
||||
raise ProtocolError('change requests need a specifier!')
|
||||
modulename, pname = specifier, 'target'
|
||||
if ':' in specifier:
|
||||
modulename, pname = specifier.split(':', 1)
|
||||
return (WRITEREPLY, specifier, list(self._setParameterValue(modulename, pname, data)))
|
||||
|
||||
def handle_do(self, conn, specifier, data):
|
||||
if not specifier:
|
||||
raise ProtocolError('do requests need a specifier!')
|
||||
modulename, cmd = specifier.split(':', 1)
|
||||
return (COMMANDREPLY, specifier, list(self._execute_command(modulename, cmd, data)))
|
||||
|
||||
|
Reference in New Issue
Block a user