From 6a60b61d37651c9a7a71bbf5246961c45ba50ef7 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Fri, 25 Nov 2022 18:38:39 +0100 Subject: [PATCH] Agent on/off --- privatedev/config/tnc/observatory_tnc.yml | 4 ++-- src/core/pyros_django/agent/Agent.py | 8 +++----- src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html | 4 ++-- src/pyros_logger.py | 4 ++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/privatedev/config/tnc/observatory_tnc.yml b/privatedev/config/tnc/observatory_tnc.yml index a69dbf9..641ef37 100644 --- a/privatedev/config/tnc/observatory_tnc.yml +++ b/privatedev/config/tnc/observatory_tnc.yml @@ -370,7 +370,7 @@ OBSERVATORY: name: AgentImagesProcessor_tnc_up1_ep computer: EtienneComputer protocol: privatedev/plugin/agent/AgentImagesProcessor_tnc_up1.py - is_active: False + is_active: True - AGENT: name: AgentSST3 computer: EtienneComputer @@ -380,7 +380,7 @@ OBSERVATORY: computer: EtienneComputer protocol: private/plugin/agent/AgentTriton.py path: private/plugin/agent/triton - is_active: False + is_active: True # Basic Agent (for EP, to test the Agent base class) - AGENT: name: AgentBasic diff --git a/src/core/pyros_django/agent/Agent.py b/src/core/pyros_django/agent/Agent.py index fc1bb0c..b74a4e7 100755 --- a/src/core/pyros_django/agent/Agent.py +++ b/src/core/pyros_django/agent/Agent.py @@ -630,6 +630,7 @@ class Agent: #self._set_mode(MODES.) log.addHandler(handler_filebyagent(logging.INFO, self.__class__.__name__)) + #log.addHandler(handler_filebyagent(logging.INFO, self.name)) log.debug("start Agent init") obs_config_file_path = os.environ["PATH_TO_OBSCONF_FILE"] path_to_obs_config_folder = os.environ["PATH_TO_OBSCONF_FOLDER"] @@ -1192,10 +1193,7 @@ class Agent: # TEST MODE only : send next command from test scenario (not waiting for current cmd to be finished) #if self.is_in_test_mode(): - print("**********************************************************") - print("AVANT") self.__TEST_send_next_test_cmd() - print("fini") #self.printd("====== END COMMMANDS PROCESSING ======") @@ -1416,7 +1414,7 @@ class Agent: # (also to let another agent having the chance to send a me command) if self.__DELAY_NB_SEC : #random_waiting_sec = random.randint(0,5) - log.info(f"Waiting {self.__DELAY_NB_SEC} sec (random) before starting new iteration...") + log.debug(f"Waiting {self.__DELAY_NB_SEC} sec (random) before starting new iteration...") #time.sleep(random_waiting_sec) self.waitfor(self.__DELAY_NB_SEC) @@ -1686,7 +1684,7 @@ class Agent: """ def sleep(self, nbsec:float): - log.info(f"Now, waiting (sleeping) for {nbsec} second(s)...") + log.debug(f"Now, waiting (sleeping) for {nbsec} second(s)...") # thread if self.__CC_thread and isinstance(self.__CC_thread, StoppableThreadEvenWhenSleeping): #and self.RUN_IN_THREAD: diff --git a/src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html b/src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html index 3798dc0..f62d1c3 100644 --- a/src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html +++ b/src/core/pyros_django/dashboard/templates/dashboard/agent_detail.html @@ -481,10 +481,10 @@ fetch("/api/agent_survey/{{agent_name}}?format=json").then(response => response.json()).then(function(data){ app2.agent = data; if (data.status == "EXITING"){ - $("#agent_title").text(data.name + " is not available").css("color","red") + $("#agent_title").text(data.name + " (OFF)").css("color","red") } else{ - $("#agent_title").text(data.name + " is available").css("color","green") + $("#agent_title").text(data.name + " (ON)").css("color","green") } if (previous_status != data.status){ diff --git a/src/pyros_logger.py b/src/pyros_logger.py index 83a9e59..36d54c1 100755 --- a/src/pyros_logger.py +++ b/src/pyros_logger.py @@ -42,8 +42,12 @@ class _FilterOnDebugModeAndNoLevelINFO(logging.Filter): # On affiche TOUJOURS sur la console SAUF level debug si mode DEBUG is OFF #print("level name", logging.getLevelName(logRecord.levelno)) #if logRecord.levelno != 10: return True + + #''' if logging.getLevelName(logRecord.levelno) == 'INFO': return False if logging.getLevelName(logRecord.levelno) == 'DEBUG': return (debug_mode == 1) + #''' + return True # On n'affiche sur la console QUE si mode DEBUG is ON #return (debug_mode == 1) -- libgit2 0.21.2