Commit 1049ca96da848317cef286ff0efdc1f20da68fee

Authored by Etienne Pallier
1 parent dbe1a54d
Exists in dev

bugfix get_all_cmds

CHANGELOG
1   -18-11-2022 (EP): v0.6.10.2
  1 +18-11-2022 (EP): v0.6.10.3
2 2 - bugfix CC_PREV
3 3 - bugfix TEST_MAX_DURATION_SEC
  4 + - bugfix get_all_cmds()
4 5 - cleanup
5 6  
6 7 15-11-2022 (EP): v0.6.10.1
... ...
VERSION
1   -0.6.10.2
2 1 \ No newline at end of file
  2 +0.6.10.3
3 3 \ No newline at end of file
... ...
privatedev/plugin/agent/AgentBasic.py
... ... @@ -28,7 +28,7 @@ class AgentBasic(Agent):
28 28 # Run the assertion tests at the end
29 29 TEST_WITH_FINAL_TEST = False
30 30 #TEST_MAX_DURATION_SEC = None
31   - TEST_MAX_DURATION_SEC = 400
  31 + TEST_MAX_DURATION_SEC = 100
32 32 # Who should I send commands to ?
33 33 TEST_COMMANDS_DEST = "myself"
34 34 #TEST_COMMANDS_DEST = "AgentB"
... ...
src/core/pyros_django/agent/Agent.py
... ... @@ -588,11 +588,11 @@ class Agent:
588 588 self.__ROUTINE_ITER_END_IS_RUNNING:bool = False
589 589 self.__test_cmd_received_num:int = 0 # only for tests
590 590 # Current Command running
591   - self.__CC :Optional(AgentCmd) = None
  591 + self.__CC :Optional[AgentCmd] = None
592 592 # Previous Command running
593   - self.__CC_prev :Optional(AgentCmd) = None
  593 + self.__CC_prev :Optional[AgentCmd] = None
594 594 # Current Command exception (if occurs)
595   - self.__CCE :Optional(Exception) = None
  595 + self.__CCE :Optional[Exception] = None
596 596 self.name = "Generic Agent"
597 597 self.__status :str = None
598 598 self.__mode :str = None
... ... @@ -1209,7 +1209,7 @@ class Agent:
1209 1209 self.__start_cmd(cmd)
1210 1210 except Exception as e:
1211 1211 self.__CCE=e
1212   - pass
  1212 + #pass
1213 1213 log.info("*"*10 + " NEXT CMD RECEIVED PROCESSING (END) " + "*"*10 + "\n")
1214 1214  
1215 1215  
... ... @@ -1383,6 +1383,7 @@ class Agent:
1383 1383 # (Test only)
1384 1384 # EXIT because max duration reached ?
1385 1385 if self.TEST_MODE and self.TEST_MAX_DURATION_SEC and (time.time()-self.start_time > self.TEST_MAX_DURATION_SEC):
  1386 + print("Exit because of max duration set to " + str(self.TEST_MAX_DURATION_SEC) + "s")
1386 1387 log.info("Exit because of max duration set to " + str(self.TEST_MAX_DURATION_SEC) + "s")
1387 1388 #self._kill_running_device_cmd_if_exists(self.name)
1388 1389 self.__cleanup_before_exit(self.name)
... ... @@ -1477,7 +1478,8 @@ class Agent:
1477 1478  
1478 1479  
1479 1480 # Misnamed command => CMD_INVALID
1480   - if not AgentCmd.is_generic_name(cmd.name) and not self.is_native_device_command(cmd.name):
  1481 + #if not AgentCmd.is_generic_name(cmd.name) and not self.is_native_device_command(cmd.name):
  1482 + if not cmd.is_generic() and not self.is_native_device_command(cmd.name):
1481 1483 cmd.set_as_invalid("Command misnamed, must start with do_, get_, or set_")
1482 1484 return #cmd
1483 1485  
... ... @@ -2032,7 +2034,8 @@ class Agent:
2032 2034 # misnamed ?
2033 2035 #FIXME:
2034 2036 #elif not cmd.is_generic():
2035   - elif not AgentCmd.is_generic(cmd.name):
  2037 + #elif not AgentCmd.is_generic(cmd.name):
  2038 + elif not cmd.is_generic():
2036 2039 cmd.set_as_invalid()
2037 2040 # unknown ?
2038 2041 elif self.is_agent_specific_cmd(cmd):
... ... @@ -2383,10 +2386,13 @@ class Agent:
2383 2386  
2384 2387 # Replace low level exception with high level one (CmdExceptionBadArgs)
2385 2388 except (TypeError, AttributeError, ValueError, CmdExceptionBadArgs, AssertionError) as e:
  2389 + print("EXCEPTION !!!")
  2390 + print(type(e))
  2391 + print(e)
2386 2392 # set back to PENDING because this command should never has been RUNNING
2387 2393 cmd.set_as_pending()
2388 2394 raise CmdExceptionBadArgs(cmd) from None
2389   -
  2395 +
2390 2396 # Replace any other exception raised during execution with high level one (CmdExceptionExecError)
2391 2397 except Exception as e:
2392 2398 #cmd.set_as_exec_error()
... ... @@ -2398,6 +2404,8 @@ class Agent:
2398 2404 ##tb = sys.exc_info()[2]
2399 2405 ##raise AgentCmdUnimplementedException(cmd).with_traceback(tb)
2400 2406 ##raise AgentCmdUnimplementedException(cmd).with_traceback(None)
  2407 + print("YESSS")
  2408 +
2401 2409  
2402 2410  
2403 2411 def is_agent_level_cmd(self, cmd:AgentCmd):
... ... @@ -2483,7 +2491,7 @@ class Agent:
2483 2491 cmds += cmd_name
2484 2492  
2485 2493 # 1) Error case 1 - Misnamed (Invalid syntax) command (not get, set, do) (implemented or not)
2486   - if not AgentCmd.is_generic(cmd_name):
  2494 + if not AgentCmd.is_generic_name(cmd_name):
2487 2495 cmds += '(I);'
2488 2496 continue
2489 2497  
... ...
src/core/pyros_django/agent/AgentBasic.py
... ... @@ -28,7 +28,7 @@ class AgentBasic(Agent):
28 28 # Run the assertion tests at the end
29 29 TEST_WITH_FINAL_TEST = False
30 30 #TEST_MAX_DURATION_SEC = None
31   - TEST_MAX_DURATION_SEC = 400
  31 + TEST_MAX_DURATION_SEC = 100
32 32 # Who should I send commands to ?
33 33 TEST_COMMANDS_DEST = "myself"
34 34 #TEST_COMMANDS_DEST = "AgentB"
... ...