Commit 471cc5b9c97d0c8826f2dbde984e6c58ad05ffbd
1 parent
cf8b1025
Exists in
dev
Déplacé AgentM dans src/monitoring/ (pyros start agentM)
Pour démarrer AgentM : "./pyros.py start agentM"
Showing
4 changed files
with
20 additions
and
5 deletions
Show diff stats
README.md
... | ... | @@ -71,9 +71,9 @@ Date: 29/03/2019 |
71 | 71 | |
72 | 72 | Author: E. Pallier |
73 | 73 | |
74 | -VERSION: 0.20.32 | |
74 | +VERSION: 0.20.33 | |
75 | 75 | |
76 | -Comment: Implémenté la commande "restart_init" (voir doc "play with a pyros agent") | |
76 | +Comment: Déplacé AgentM dans src/monitoring/ (pyros start agentM) | |
77 | 77 | |
78 | 78 | - Scenario de test : |
79 | 79 | - lancer agents A et B en mode simu (option -t): ./pyros.py -t start agentA,agentB |
... | ... | @@ -88,6 +88,7 @@ Comment: Implémenté la commande "restart_init" (voir doc "play with a pyros ag |
88 | 88 | - pour utiliser thread ou processus : il suffit de mettre la constante RUN_IN_THREAD de AgentA (ou AgentB ou AgentX) à False ou True |
89 | 89 | |
90 | 90 | - Historique des nouveautés implémentées : |
91 | + - Implémenté la commande "restart_init" (voir doc "play with a pyros agent") et refactorisation de run() | |
91 | 92 | - Implémenté le "abort" dans le simulateur |
92 | 93 | - Optimisation log_agent_status() (ex update_survey()) |
93 | 94 | - AgentM (début) pour remplacer progressivement l'agent monitoring | ... | ... |
pyros.py
... | ... | @@ -391,9 +391,15 @@ def start(agent:str, configfile:str): |
391 | 391 | cmd = "manage.py runserver" |
392 | 392 | os.chdir("src") |
393 | 393 | #if not test_mode(): execProcessFromVenv("start_agent.py " + agent_name + " " + configfile) |
394 | + | |
395 | + elif agent_name == "agentM": | |
396 | + os.chdir("src/monitoring/") | |
397 | + cmd = f"Agent{agent_name[5:]}.py" | |
398 | + if test_mode(): cmd += " -t" | |
399 | + if configfile: cmd += " {configfile}" | |
394 | 400 | |
395 | 401 | # Agent "agentA", "agentB", "agentX", ... |
396 | - if agent_name.startswith("agent"): | |
402 | + elif agent_name.startswith("agent"): | |
397 | 403 | # Run agent without actual commands sent to devices (FOR_REAL=False) |
398 | 404 | ##agentX.run(FOR_REAL=True) |
399 | 405 | os.chdir("src/agent/") | ... | ... |
src/agent/Agent.py
... | ... | @@ -418,11 +418,19 @@ class Agent: |
418 | 418 | config_filename = self.DEFAULT_CONFIG_FILE_NAME |
419 | 419 | |
420 | 420 | self.printd(f"config_filename={config_filename}") |
421 | + | |
421 | 422 | # If config file name is RELATIVE (i.e. without path, just the file name) |
422 | 423 | # => give it an absolute path (and remove "src/agent/" from it) |
423 | 424 | if config_filename == os.path.basename(config_filename): |
424 | - tmp = os.path.abspath(self.CONFIG_DIR + os.sep + config_filename) | |
425 | - config_filename = os.path.abspath(self.CONFIG_DIR + os.sep + config_filename).replace(os.sep+"src"+os.sep,os.sep).replace(os.sep+"agent"+os.sep,os.sep) | |
425 | + # Build abs path including current agent dir | |
426 | + config_filename = os.path.abspath(self.CONFIG_DIR + os.sep + config_filename) | |
427 | + # Remove "src/agent_name/" from abs dir : | |
428 | + # (1) Remove "src/" | |
429 | + config_filename = config_filename.replace(os.sep+"src"+os.sep,os.sep) | |
430 | + # (2) Remove "agent_name/" | |
431 | + #TODO: bidouille, faire plus propre | |
432 | + config_filename = config_filename.replace(os.sep+"agent"+os.sep,os.sep) | |
433 | + config_filename = config_filename.replace(os.sep+"monitoring"+os.sep,os.sep) | |
426 | 434 | self.printd("Config file used is", config_filename) |
427 | 435 | #self.printd("current path", os.getcwd()) |
428 | 436 | #self.printd("this file path :", __file__) | ... | ... |
src/agent/AgentM.py renamed to src/monitoring/AgentM.py