From f7515901c6c9d37732ae802085ada91e180c749a Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Tue, 28 Jun 2022 18:24:59 +0200 Subject: [PATCH] Agent bugfix --- src/core/pyros_django/agent/Agent.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/core/pyros_django/agent/Agent.py b/src/core/pyros_django/agent/Agent.py index 46316f2..0476a6e 100755 --- a/src/core/pyros_django/agent/Agent.py +++ b/src/core/pyros_django/agent/Agent.py @@ -332,6 +332,7 @@ class Agent: AGENT_SPECIFIC_COMMANDS = [ "do_specific1", "set_specific2", + "do_specific3", ] # @@ -416,12 +417,14 @@ class Agent: # 2) NORMAL CASES (test scenario) + # Agent general command "Agent set_mode ATTENTIVE", # => should get "ATTENTIVE" - "self get_mode", + "self get_mode", - # Agent specific command => should be executed + # Agent specific commands => should be executed + "self do_specific3", "self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", "self set_mode ROUTINE", @@ -1965,20 +1968,21 @@ class Agent: methods_list = [method for method in dir(self) if callable(getattr(self, method))] #print(methodsList) func = cmd.name - args = [] + if func not in methods_list: raise AgentCmdUnimplementedException(cmd) #for arg in cmd.args: print(arg) - for arg in cmd.args: - #print(arg) - #try: - # Evaluate arg only if it is not a word (letters) - if not arg[0].isalpha(): - arg = ast.literal_eval(arg) - #except ValueError as e: newarg = arg - args.append(arg) - print(args) + if cmd.args: + args = [] + for arg in cmd.args: + #print(arg) + #try: + # Evaluate arg only if it is not a word (letters) + if not arg[0].isalpha(): + arg = ast.literal_eval(arg) + #except ValueError as e: newarg = arg + args.append(arg) + #print(args) #print(cmd.args) #print(*cmd.args) - if func not in methods_list: raise AgentCmdUnimplementedException(cmd) try: if cmd.args: # equivalent to calling self.func(*cmd.args) @@ -2066,6 +2070,9 @@ class Agent: #def set_specific2(self, arg1:str, arg2:int): pass + def do_specific3(self): + pass + ### # ================================================================================================ -- libgit2 0.21.2