Skip to content
Snippets Groups Projects
Commit 7dce87f8 authored by shinedday's avatar shinedday
Browse files

fix the update

parent 64911e7f
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,9 @@ from iotAmak.tool.ssh_client import SSHClient, Cmd ...@@ -16,7 +16,9 @@ from iotAmak.tool.ssh_client import SSHClient, Cmd
class Ihm(MqttClient, SSHClient): 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) self.broker_ip = read_broker(config_path)
MqttClient.__init__(self, self.broker_ip, "Ihm") MqttClient.__init__(self, self.broker_ip, "Ihm")
SSHClient.__init__(self, read_ssh(config_path)) SSHClient.__init__(self, read_ssh(config_path))
...@@ -117,7 +119,22 @@ class Ihm(MqttClient, SSHClient): ...@@ -117,7 +119,22 @@ class Ihm(MqttClient, SSHClient):
if cmd.lower() == "update": if cmd.lower() == "update":
commands = [ commands = [
Cmd( 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): ...@@ -125,7 +142,7 @@ class Ihm(MqttClient, SSHClient):
print("Hostname :", self.clients[i_client].hostname, " User :", self.clients[i_client].user) print("Hostname :", self.clients[i_client].hostname, " User :", self.clients[i_client].user)
self.run_cmd(i_client, commands) self.run_cmd(i_client, commands)
self.update() self.update(self.experiment_name)
# Crée les processus amas/env/scheduler de l'experience chargé # Crée les processus amas/env/scheduler de l'experience chargé
if cmd.lower() == "start": if cmd.lower() == "start":
......
...@@ -44,13 +44,13 @@ class SSHClient: ...@@ -44,13 +44,13 @@ class SSHClient:
print("pxssh failed on login.") print("pxssh failed on login.")
print(e) print(e)
def update(self): def update(self, experiment_name):
for client in self.clients: for client in self.clients:
transport = paramiko.Transport((client.hostname, 22)) transport = paramiko.Transport((client.hostname, 22))
transport.connect(username=client.user, password=client.password) transport.connect(username=client.user, password=client.password)
sftp = MySFTPClient.from_transport(transport) sftp = MySFTPClient.from_transport(transport)
sftp.mkdir("./Desktop/mqtt_goyon/iotamak-core", ignore_existing=True) sftp.mkdir("Desktop/mqtt_goyon/example/" + experiment_name, ignore_existing=True)
sftp.put_dir("/mnt/d/work/stage m1/iotamak-core", "./Desktop/mqtt_goyon/iotamak-core") sftp.put_dir("../"+experiment_name, "Desktop/mqtt_goyon/example/" + experiment_name)
sftp.close() sftp.close()
class MySFTPClient(paramiko.SFTPClient): class MySFTPClient(paramiko.SFTPClient):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment