diff --git a/agent.py b/agent.py index 3d79a4a59b943b7e1918654cbf09063d7873e926..9d136245d9b2b0865d27341b6add81131e096cdb 100644 --- a/agent.py +++ b/agent.py @@ -2,7 +2,7 @@ import sys from ast import literal_eval from typing import Dict -from schedulable import Schedulable +from tool.schedulable import Schedulable class Agent(Schedulable): diff --git a/amas.py b/amas.py index 35e947d9aaf22b22b8065a2a19eb3b1653b44e28..1ff3e9de7c8a6227d2f201381c357aba56e53bfc 100644 --- a/amas.py +++ b/amas.py @@ -2,10 +2,9 @@ Amas class """ from ast import literal_eval -from pexpect import pxssh -from schedulable import Schedulable -from ssh_client import SSHClient, Cmd +from tool.schedulable import Schedulable +from tool.ssh_client import SSHClient, Cmd class Amas(Schedulable, SSHClient): diff --git a/environment.py b/environment.py index 562a268947d54242af3ee38c8248a4122d13975a..1d5b90c65016387112fe278ea4dee4d5501498e6 100644 --- a/environment.py +++ b/environment.py @@ -2,7 +2,7 @@ Environment class """ -from schedulable import Schedulable +from tool.schedulable import Schedulable class Environment(Schedulable): diff --git a/ihm.py b/ihm.py index 9236072694c623cfbbe317c41faaf04907f1e898..83f601ac9e5be42a857a83ea365e047f979c7cc8 100644 --- a/ihm.py +++ b/ihm.py @@ -3,9 +3,9 @@ from subprocess import Popen from os import path from time import sleep -from mqtt_client import MqttClient -from ssh_client import SSHClient, Cmd, RemoteClient -from update import VersionManager +from tool.mqtt_client import MqttClient +from tool.ssh_client import SSHClient, Cmd, RemoteClient +from tool.update import VersionManager class Ihm(MqttClient, SSHClient): diff --git a/philosophers/amas.py b/philosophers/amas.py index e5bc0edf81a7305de43a334a357e8253ef987283..2e2049a6bc983599326ade45b98fc6b442f9a978 100644 --- a/philosophers/amas.py +++ b/philosophers/amas.py @@ -4,7 +4,7 @@ import pathlib sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) from amas import Amas -from ssh_client import Cmd +from tool.ssh_client import Cmd class PhiAmas(Amas): @@ -33,5 +33,5 @@ class PhiAmas(Amas): # self.run_cmd(1, agents[2:]) if __name__ == '__main__': - s = PhiAmas(3) + s = PhiAmas(100) s.run() \ No newline at end of file diff --git a/philosophers/env.py b/philosophers/env.py index 179ba88d2ab8589d2f7e17e4f3943d1673e0b673..9f043ce7f1b5b4f264b5e3efc081f765b2e36c70 100644 --- a/philosophers/env.py +++ b/philosophers/env.py @@ -65,5 +65,5 @@ class PhiEnv(Environment): if __name__ == '__main__': - s = PhiEnv(3) + s = PhiEnv(100) s.run() \ No newline at end of file diff --git a/scheduler.py b/scheduler.py index 652345fe909ef79c4d533a25fc0cb6743252222e..5355e4ff81befb973da0d82267953c9d39e6fec0 100644 --- a/scheduler.py +++ b/scheduler.py @@ -1,7 +1,7 @@ import sys from time import sleep -from schedulable import Schedulable +from tool.schedulable import Schedulable class Scheduler(Schedulable): diff --git a/tool/__init__.py b/tool/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tool/confi_reader.py b/tool/confi_reader.py new file mode 100644 index 0000000000000000000000000000000000000000..cef7a3633606c6595d573a194fd28848bd1e91c9 --- /dev/null +++ b/tool/confi_reader.py @@ -0,0 +1,24 @@ +import json + +from tool.ssh_client import RemoteClient + + +def read_ssh(path): + + with open(path, 'r', encoding='utf-8') as f: + dict = json.load(f) + + res = [] + for client in dict.get("clients_ssh"): + res.append(RemoteClient( + hostname=client.get("hostname"), + user=client.get("user"), + password=client.get("password") + )) + return res + +def read_broker(path): + with open(path, 'r', encoding='utf-8') as f: + dict = json.load(f) + + return dict.get("broker") \ No newline at end of file diff --git a/tool/config.json b/tool/config.json new file mode 100644 index 0000000000000000000000000000000000000000..274c0747ced40ac9efe87b76055f8fc1a2c1e372 --- /dev/null +++ b/tool/config.json @@ -0,0 +1,25 @@ +{ + "broker" : "192.168.1.1", + "clients_ssh" : [ + { + "hostname" : "192.168.1.1", + "user" : "pi", + "password" : "raspberry" + }, + { + "hostname" : "192.168.1.1", + "user" : "pi", + "password" : "raspberry" + }, + { + "hostname" : "192.168.1.1", + "user" : "pi", + "password" : "raspberry" + }, + { + "hostname" : "192.168.1.1", + "user" : "pi", + "password" : "raspberry" + } + ] +} \ No newline at end of file diff --git a/mqtt_client.py b/tool/mqtt_client.py similarity index 100% rename from mqtt_client.py rename to tool/mqtt_client.py diff --git a/schedulable.py b/tool/schedulable.py similarity index 95% rename from schedulable.py rename to tool/schedulable.py index 16a2150cacae02a6f620168a90490d516818e808..293f35f5287bebacf597e976f2d09e9b885e5e41 100644 --- a/schedulable.py +++ b/tool/schedulable.py @@ -3,7 +3,7 @@ Tool class that implement basic interaction that help to finish processes """ from time import sleep -from mqtt_client import MqttClient +from tool.mqtt_client import MqttClient class Schedulable(MqttClient): diff --git a/ssh_client.py b/tool/ssh_client.py similarity index 100% rename from ssh_client.py rename to tool/ssh_client.py diff --git a/update.py b/tool/update.py similarity index 97% rename from update.py rename to tool/update.py index 43d43e2bc570d9103bc0ecb8b084a8af375d7d84..8d923f717c17202f0b1cbfb2b359fae41ad622b8 100644 --- a/update.py +++ b/tool/update.py @@ -1,7 +1,7 @@ import paramiko import os -from ssh_client import RemoteClient +from tool.ssh_client import RemoteClient class VersionManager: