diff --git a/iotAmak/ihm.py b/iotAmak/ihm.py index 1347488bef00492a8b281a124ea8250e30911426..5c3db3174281d70518278617e7102c2ddd9785f8 100644 --- a/iotAmak/ihm.py +++ b/iotAmak/ihm.py @@ -16,7 +16,9 @@ from iotAmak.tool.ssh_client import SSHClient, Cmd class Ihm(MqttClient, SSHClient): - def __init__(self, config_path): + def __init__(self, config_path, experiment_name, version="0.0.1"): + self.version = version + self.experiment_name = experiment_name self.broker_ip = read_broker(config_path) MqttClient.__init__(self, self.broker_ip, "Ihm") SSHClient.__init__(self, read_ssh(config_path)) @@ -117,7 +119,22 @@ class Ihm(MqttClient, SSHClient): if cmd.lower() == "update": commands = [ Cmd( - cmd="rm -r Desktop/mqtt_goyon/iotamak-core" + cmd="cd Desktop/mqtt_goyon/iotamak-core" + ), + Cmd( + cmd="git pull" + ), + Cmd( + cmd="git checkout core_to_module" + ), + Cmd( + cmd="python3 -m pip install --force-reinstall dist/iotAmak-"+self.version+"-py3-none-any.whl" + ), + Cmd( + cmd="cd ../../../" + ), + Cmd( + cmd="rm -r Desktop/mqtt_goyon/example/" + self.experiment_name ) ] @@ -125,7 +142,7 @@ class Ihm(MqttClient, SSHClient): print("Hostname :", self.clients[i_client].hostname, " User :", self.clients[i_client].user) self.run_cmd(i_client, commands) - self.update() + self.update(self.experiment_name) # Crée les processus amas/env/scheduler de l'experience chargé if cmd.lower() == "start": diff --git a/iotAmak/tool/ssh_client.py b/iotAmak/tool/ssh_client.py index 3f7d2e287c7c41066e9add3ddd73b17d26ac46ea..591b0605b9f0a125af03a8cf8d02a53e63f422d6 100644 --- a/iotAmak/tool/ssh_client.py +++ b/iotAmak/tool/ssh_client.py @@ -44,13 +44,13 @@ class SSHClient: print("pxssh failed on login.") print(e) - def update(self): + def update(self, experiment_name): for client in self.clients: transport = paramiko.Transport((client.hostname, 22)) transport.connect(username=client.user, password=client.password) sftp = MySFTPClient.from_transport(transport) - sftp.mkdir("./Desktop/mqtt_goyon/iotamak-core", ignore_existing=True) - sftp.put_dir("/mnt/d/work/stage m1/iotamak-core", "./Desktop/mqtt_goyon/iotamak-core") + sftp.mkdir("Desktop/mqtt_goyon/example/" + experiment_name, ignore_existing=True) + sftp.put_dir("../"+experiment_name, "Desktop/mqtt_goyon/example/" + experiment_name) sftp.close() class MySFTPClient(paramiko.SFTPClient):