core: better command handling
* check argument of do * automatically set optional struct members from function signature Change-Id: I95684f1826c1318ea92fad2bd4c9681d85ea72f5 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32501 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
@@ -131,6 +131,8 @@ class Dispatcher:
|
||||
self.reset_connection(conn)
|
||||
|
||||
def _execute_command(self, modulename, exportedname, argument=None):
|
||||
""" Execute a command. Importing the value is done in 'do' for nicer
|
||||
error messages."""
|
||||
moduleobj = self.secnode.get_module(modulename)
|
||||
if moduleobj is None:
|
||||
raise NoSuchModuleError(f'Module {modulename!r} does not exist')
|
||||
@@ -139,9 +141,6 @@ class Dispatcher:
|
||||
cobj = moduleobj.commands.get(cname)
|
||||
if cobj is None:
|
||||
raise NoSuchCommandError(f'Module {modulename!r} has no command {cname or exportedname!r}')
|
||||
|
||||
if cobj.argument:
|
||||
argument = cobj.argument.import_value(argument)
|
||||
# now call func
|
||||
# note: exceptions are handled in handle_request, not here!
|
||||
result = cobj.do(moduleobj, argument)
|
||||
|
||||
Reference in New Issue
Block a user