Commit f7515901c6c9d37732ae802085ada91e180c749a

Authored by Etienne Pallier
1 parent fd880010
Exists in dev

Agent bugfix

Showing 1 changed file with 20 additions and 13 deletions   Show diff stats
src/core/pyros_django/agent/Agent.py
@@ -332,6 +332,7 @@ class Agent: @@ -332,6 +332,7 @@ class Agent:
332 AGENT_SPECIFIC_COMMANDS = [ 332 AGENT_SPECIFIC_COMMANDS = [
333 "do_specific1", 333 "do_specific1",
334 "set_specific2", 334 "set_specific2",
  335 + "do_specific3",
335 ] 336 ]
336 337
337 # 338 #
@@ -416,12 +417,14 @@ class Agent: @@ -416,12 +417,14 @@ class Agent:
416 417
417 # 2) NORMAL CASES (test scenario) 418 # 2) NORMAL CASES (test scenario)
418 419
  420 +
419 # Agent general command 421 # Agent general command
420 "Agent set_mode ATTENTIVE", 422 "Agent set_mode ATTENTIVE",
421 # => should get "ATTENTIVE" 423 # => should get "ATTENTIVE"
422 - "self get_mode", 424 + "self get_mode",
423 425
424 - # Agent specific command => should be executed 426 + # Agent specific commands => should be executed
  427 + "self do_specific3",
425 "self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]", 428 "self do_specific1 1 2 3.5 titi (3,'titi',5) [1,3,5,7,9]",
426 429
427 "self set_mode ROUTINE", 430 "self set_mode ROUTINE",
@@ -1965,20 +1968,21 @@ class Agent: @@ -1965,20 +1968,21 @@ class Agent:
1965 methods_list = [method for method in dir(self) if callable(getattr(self, method))] 1968 methods_list = [method for method in dir(self) if callable(getattr(self, method))]
1966 #print(methodsList) 1969 #print(methodsList)
1967 func = cmd.name 1970 func = cmd.name
1968 - args = [] 1971 + if func not in methods_list: raise AgentCmdUnimplementedException(cmd)
1969 #for arg in cmd.args: print(arg) 1972 #for arg in cmd.args: print(arg)
1970 - for arg in cmd.args:  
1971 - #print(arg)  
1972 - #try:  
1973 - # Evaluate arg only if it is not a word (letters)  
1974 - if not arg[0].isalpha():  
1975 - arg = ast.literal_eval(arg)  
1976 - #except ValueError as e: newarg = arg  
1977 - args.append(arg)  
1978 - print(args) 1973 + if cmd.args:
  1974 + args = []
  1975 + for arg in cmd.args:
  1976 + #print(arg)
  1977 + #try:
  1978 + # Evaluate arg only if it is not a word (letters)
  1979 + if not arg[0].isalpha():
  1980 + arg = ast.literal_eval(arg)
  1981 + #except ValueError as e: newarg = arg
  1982 + args.append(arg)
  1983 + #print(args)
1979 #print(cmd.args) 1984 #print(cmd.args)
1980 #print(*cmd.args) 1985 #print(*cmd.args)
1981 - if func not in methods_list: raise AgentCmdUnimplementedException(cmd)  
1982 try: 1986 try:
1983 if cmd.args: 1987 if cmd.args:
1984 # equivalent to calling self.func(*cmd.args) 1988 # equivalent to calling self.func(*cmd.args)
@@ -2066,6 +2070,9 @@ class Agent: @@ -2066,6 +2070,9 @@ class Agent:
2066 2070
2067 #def set_specific2(self, arg1:str, arg2:int): pass 2071 #def set_specific2(self, arg1:str, arg2:int): pass
2068 2072
  2073 + def do_specific3(self):
  2074 + pass
  2075 +
2069 2076
2070 ### 2077 ###
2071 # ================================================================================================ 2078 # ================================================================================================