modify arguments of Dispatcher.announce_update
- 'pname' argument is not needed - change 'modulename' argument to 'moduleobj' (needed for further change) Change-Id: Ib21f8ad06d9b2be4005ff3513088a85e29785c94 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32744 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
2a165c5013
commit
f6f433e6b2
@ -549,7 +549,7 @@ class Module(HasAccessibles):
|
|||||||
arg = value
|
arg = value
|
||||||
pobj.readerror = None
|
pobj.readerror = None
|
||||||
if pobj.export:
|
if pobj.export:
|
||||||
self.updateCallback(self.name, pname, pobj)
|
self.updateCallback(self, pobj)
|
||||||
cblist = callbacks[pname]
|
cblist = callbacks[pname]
|
||||||
for cb in cblist:
|
for cb in cblist:
|
||||||
try:
|
try:
|
||||||
|
@ -946,6 +946,9 @@ class Attached(Property):
|
|||||||
if not modulename:
|
if not modulename:
|
||||||
return None # happens when mandatory=False and modulename is not given
|
return None # happens when mandatory=False and modulename is not given
|
||||||
modobj = obj.secNode.get_module(modulename)
|
modobj = obj.secNode.get_module(modulename)
|
||||||
|
if not modobj:
|
||||||
|
raise ConfigError(f'attached module {self.name}={modulename!r} '
|
||||||
|
f'does not exist')
|
||||||
if not isinstance(modobj, self.basecls):
|
if not isinstance(modobj, self.basecls):
|
||||||
raise ConfigError(f'attached module {self.name}={modobj.name!r} '\
|
raise ConfigError(f'attached module {self.name}={modobj.name!r} '\
|
||||||
f'must inherit from {self.basecls.__qualname__!r}')
|
f'must inherit from {self.basecls.__qualname__!r}')
|
||||||
|
@ -82,14 +82,14 @@ class Dispatcher(dispatcher.Dispatcher):
|
|||||||
super().__init__(name, log, options, srv)
|
super().__init__(name, log, options, srv)
|
||||||
self.log = srv.log # overwrite child logger
|
self.log = srv.log # overwrite child logger
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
if pobj.readerror:
|
if pobj.readerror:
|
||||||
value = repr(pobj.readerror)
|
value = repr(pobj.readerror)
|
||||||
else:
|
else:
|
||||||
value = pobj.value
|
value = pobj.value
|
||||||
logobj = self._modules.get(modulename, self)
|
logobj = self._modules.get(moduleobj.name, self)
|
||||||
# self.log.info('%s:%s %r', modulename, pname, value)
|
# self.log.info('%s:%s %r', modulename, pname, value)
|
||||||
logobj.log.info('%s %r', pname, value)
|
logobj.log.info('%s %r', pobj.name, value)
|
||||||
|
|
||||||
def register_module(self, moduleobj, modulename, export=True):
|
def register_module(self, moduleobj, modulename, export=True):
|
||||||
self.log.info('registering %s', modulename)
|
self.log.info('registering %s', modulename)
|
||||||
|
@ -94,10 +94,10 @@ class Dispatcher:
|
|||||||
for conn in listeners:
|
for conn in listeners:
|
||||||
conn.send_reply(msg)
|
conn.send_reply(msg)
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
"""called by modules param setters to notify subscribers of new values
|
"""called by modules param setters to notify subscribers of new values
|
||||||
"""
|
"""
|
||||||
self.broadcast_event(make_update(modulename, pobj))
|
self.broadcast_event(make_update(moduleobj.name, pobj))
|
||||||
|
|
||||||
def subscribe(self, conn, eventname):
|
def subscribe(self, conn, eventname):
|
||||||
self._subscriptions.setdefault(eventname, set()).add(conn)
|
self._subscriptions.setdefault(eventname, set()).add(conn)
|
||||||
|
@ -94,6 +94,7 @@ class SecNode:
|
|||||||
if modulename in list(self.modules.values()):
|
if modulename in list(self.modules.values()):
|
||||||
# it's actually already the module object
|
# it's actually already the module object
|
||||||
return modulename
|
return modulename
|
||||||
|
|
||||||
# create module from srv.module_cfg, store and return
|
# create module from srv.module_cfg, store and return
|
||||||
self.log.debug('attempting to create module %r', modulename)
|
self.log.debug('attempting to create module %r', modulename)
|
||||||
|
|
||||||
|
@ -24,29 +24,6 @@ from frappy.modules import Module, Attached
|
|||||||
from frappy.protocol.dispatcher import Dispatcher
|
from frappy.protocol.dispatcher import Dispatcher
|
||||||
|
|
||||||
|
|
||||||
# class DispatcherStub:
|
|
||||||
# # omit_unchanged_within = 0
|
|
||||||
#
|
|
||||||
# # def __init__(self, updates):
|
|
||||||
# # self.updates = updates
|
|
||||||
# #
|
|
||||||
# # def announce_update(self, modulename, pname, pobj):
|
|
||||||
# # self.updates.setdefault(modulename, {})
|
|
||||||
# # if pobj.readerror:
|
|
||||||
# # self.updates[modulename]['error', pname] = str(pobj.readerror)
|
|
||||||
# # else:
|
|
||||||
# # self.updates[modulename][pname] = pobj.value
|
|
||||||
#
|
|
||||||
# def __init__(self):
|
|
||||||
# self.modules = {}
|
|
||||||
#
|
|
||||||
# def get_module(self, name):
|
|
||||||
# return self.modules[name]
|
|
||||||
#
|
|
||||||
# def register_module(self, name, module):
|
|
||||||
# self.modules[name] = module
|
|
||||||
|
|
||||||
|
|
||||||
class LoggerStub:
|
class LoggerStub:
|
||||||
def debug(self, fmt, *args):
|
def debug(self, fmt, *args):
|
||||||
print(fmt % args)
|
print(fmt % args)
|
||||||
|
@ -37,12 +37,13 @@ class DispatcherStub:
|
|||||||
generalConfig.testinit(omit_unchanged_within=0)
|
generalConfig.testinit(omit_unchanged_within=0)
|
||||||
self.updates = updates
|
self.updates = updates
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
|
modulename = moduleobj.name
|
||||||
self.updates.setdefault(modulename, {})
|
self.updates.setdefault(modulename, {})
|
||||||
if pobj.readerror:
|
if pobj.readerror:
|
||||||
self.updates[modulename]['error', pname] = str(pobj.readerror)
|
self.updates[modulename]['error', pobj.name] = str(pobj.readerror)
|
||||||
else:
|
else:
|
||||||
self.updates[modulename][pname] = pobj.value
|
self.updates[modulename][pobj.name] = pobj.value
|
||||||
|
|
||||||
|
|
||||||
class LoggerStub:
|
class LoggerStub:
|
||||||
|
@ -44,12 +44,13 @@ class DispatcherStub:
|
|||||||
generalConfig.testinit(omit_unchanged_within=0)
|
generalConfig.testinit(omit_unchanged_within=0)
|
||||||
self.updates = updates
|
self.updates = updates
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
|
modulename = moduleobj.name
|
||||||
self.updates.setdefault(modulename, {})
|
self.updates.setdefault(modulename, {})
|
||||||
if pobj.readerror:
|
if pobj.readerror:
|
||||||
self.updates[modulename]['error', pname] = str(pobj.readerror)
|
self.updates[modulename]['error', pobj.name] = str(pobj.readerror)
|
||||||
else:
|
else:
|
||||||
self.updates[modulename][pname] = pobj.value
|
self.updates[modulename][pobj.name] = pobj.value
|
||||||
|
|
||||||
|
|
||||||
class LoggerStub:
|
class LoggerStub:
|
||||||
@ -707,10 +708,10 @@ def test_super_call():
|
|||||||
def __init__(self, updates):
|
def __init__(self, updates):
|
||||||
self.updates = updates
|
self.updates = updates
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
if pobj.readerror:
|
if pobj.readerror:
|
||||||
raise pobj.readerror
|
raise pobj.readerror
|
||||||
self.updates.append((modulename, pname, pobj.value))
|
self.updates.append((moduleobj.name, pobj.name, pobj.value))
|
||||||
|
|
||||||
class ServerStub1:
|
class ServerStub1:
|
||||||
def __init__(self, updates):
|
def __init__(self, updates):
|
||||||
|
@ -35,7 +35,7 @@ class SecNodeStub:
|
|||||||
|
|
||||||
|
|
||||||
class DispatcherStub:
|
class DispatcherStub:
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ artime = Time() # artificial test time
|
|||||||
class DispatcherStub:
|
class DispatcherStub:
|
||||||
maxcycles = 10
|
maxcycles = 10
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
now = artime.time()
|
now = artime.time()
|
||||||
if hasattr(pobj, 'stat'):
|
if hasattr(pobj, 'stat'):
|
||||||
pobj.stat.append(now)
|
pobj.stat.append(now)
|
||||||
|
@ -195,12 +195,12 @@ class DispatcherStub:
|
|||||||
generalConfig.testinit(omit_unchanged_within=0)
|
generalConfig.testinit(omit_unchanged_within=0)
|
||||||
self.updates = updates
|
self.updates = updates
|
||||||
|
|
||||||
def announce_update(self, modulename, pname, pobj):
|
def announce_update(self, moduleobj, pobj):
|
||||||
assert modulename == 'obj'
|
assert moduleobj.name == 'obj'
|
||||||
if pobj.readerror:
|
if pobj.readerror:
|
||||||
self.updates.append((pname, pobj.readerror))
|
self.updates.append((pobj.name, pobj.readerror))
|
||||||
else:
|
else:
|
||||||
self.updates.append((pname, pobj.value))
|
self.updates.append((pobj.name, pobj.value))
|
||||||
|
|
||||||
|
|
||||||
class ServerStub:
|
class ServerStub:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user