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:
2023-12-11 17:41:56 +01:00
parent 8142ba746d
commit 841ef224f6
11 changed files with 27 additions and 44 deletions

View File

@ -24,29 +24,6 @@ from frappy.modules import Module, Attached
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:
def debug(self, fmt, *args):
print(fmt % args)

View File

@ -37,12 +37,13 @@ class DispatcherStub:
generalConfig.testinit(omit_unchanged_within=0)
self.updates = updates
def announce_update(self, modulename, pname, pobj):
def announce_update(self, moduleobj, pobj):
modulename = moduleobj.name
self.updates.setdefault(modulename, {})
if pobj.readerror:
self.updates[modulename]['error', pname] = str(pobj.readerror)
self.updates[modulename]['error', pobj.name] = str(pobj.readerror)
else:
self.updates[modulename][pname] = pobj.value
self.updates[modulename][pobj.name] = pobj.value
class LoggerStub:

View File

@ -44,12 +44,13 @@ class DispatcherStub:
generalConfig.testinit(omit_unchanged_within=0)
self.updates = updates
def announce_update(self, modulename, pname, pobj):
def announce_update(self, moduleobj, pobj):
modulename = moduleobj.name
self.updates.setdefault(modulename, {})
if pobj.readerror:
self.updates[modulename]['error', pname] = str(pobj.readerror)
self.updates[modulename]['error', pobj.name] = str(pobj.readerror)
else:
self.updates[modulename][pname] = pobj.value
self.updates[modulename][pobj.name] = pobj.value
class LoggerStub:
@ -707,10 +708,10 @@ def test_super_call():
def __init__(self, updates):
self.updates = updates
def announce_update(self, modulename, pname, pobj):
def announce_update(self, moduleobj, pobj):
if pobj.readerror:
raise pobj.readerror
self.updates.append((modulename, pname, pobj.value))
self.updates.append((moduleobj.name, pobj.name, pobj.value))
class ServerStub1:
def __init__(self, updates):

View File

@ -35,7 +35,7 @@ class SecNodeStub:
class DispatcherStub:
def announce_update(self, modulename, pname, pobj):
def announce_update(self, moduleobj, pobj):
pass

View File

@ -53,7 +53,7 @@ artime = Time() # artificial test time
class DispatcherStub:
maxcycles = 10
def announce_update(self, modulename, pname, pobj):
def announce_update(self, moduleobj, pobj):
now = artime.time()
if hasattr(pobj, 'stat'):
pobj.stat.append(now)

View File

@ -195,12 +195,12 @@ class DispatcherStub:
generalConfig.testinit(omit_unchanged_within=0)
self.updates = updates
def announce_update(self, modulename, pname, pobj):
assert modulename == 'obj'
def announce_update(self, moduleobj, pobj):
assert moduleobj.name == 'obj'
if pobj.readerror:
self.updates.append((pname, pobj.readerror))
self.updates.append((pobj.name, pobj.readerror))
else:
self.updates.append((pname, pobj.value))
self.updates.append((pobj.name, pobj.value))
class ServerStub: