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

Fix intent and typo

parent 0eb830c2
No related branches found
No related tags found
No related merge requests found
import pathlib
import platform # For getting the operating system name
import subprocess # For executing a shell command
import sys import sys
from subprocess import Popen
from os import path from os import path
from subprocess import Popen
from time import sleep from time import sleep
import platform # For getting the operating system name
import subprocess # For executing a shell command
import pathlib
from tool.confi_reader import read_ssh from tool.confi_reader import read_ssh
from tool.mqtt_client import MqttClient from tool.mqtt_client import MqttClient
from tool.ssh_client import SSHClient, Cmd from tool.ssh_client import SSHClient, Cmd
from tool.update import VersionManager from tool.update import VersionManager
class Ihm(MqttClient, SSHClient): class Ihm(MqttClient, SSHClient):
def __init__(self): def __init__(self):
...@@ -111,9 +110,9 @@ class Ihm(MqttClient, SSHClient): ...@@ -111,9 +110,9 @@ class Ihm(MqttClient, SSHClient):
p1 = Popen([sys.executable, 'scheduler.py', cmd]) p1 = Popen([sys.executable, 'scheduler.py', cmd])
sleep(1) sleep(1)
# start subprocess amas # start subprocess amas
p2 = Popen([sys.executable, experiment_folder+'/amas.py']) p2 = Popen([sys.executable, experiment_folder + '/amas.py'])
# start subprocess env # start subprocess env
p3 = Popen([sys.executable, experiment_folder+'/env.py']) p3 = Popen([sys.executable, experiment_folder + '/env.py'])
if cmd.lower() == "pause": if cmd.lower() == "pause":
self.client.publish("ihm/pause") self.client.publish("ihm/pause")
...@@ -126,8 +125,7 @@ class Ihm(MqttClient, SSHClient): ...@@ -126,8 +125,7 @@ class Ihm(MqttClient, SSHClient):
if cmd.lower() == "ping": if cmd.lower() == "ping":
for client in read_ssh(str(pathlib.Path(__file__).parent.resolve())+"/tool/config.json") : for client in read_ssh(str(pathlib.Path(__file__).parent.resolve()) + "/tool/config.json"):
param = '-n' if platform.system().lower() == 'windows' else '-c' param = '-n' if platform.system().lower() == 'windows' else '-c'
command = ['ping', param, '1', client.hostname] command = ['ping', param, '1', client.hostname]
...@@ -138,12 +136,10 @@ class Ihm(MqttClient, SSHClient): ...@@ -138,12 +136,10 @@ class Ihm(MqttClient, SSHClient):
if cmd.lower() == "mode": if cmd.lower() == "mode":
self.client.publish("ihm/mode") self.client.publish("ihm/mode")
self.client.publish("ihm/step") self.client.publish("ihm/step")
sleep(2) sleep(2)
if __name__ == '__main__': if __name__ == '__main__':
a = Ihm() a = Ihm()
a.run() a.run()
import json import json
import sys
import pathlib import pathlib
import sys
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
from tool.remote_client import RemoteClient from tool.remote_client import RemoteClient
......
import sys
import pathlib import pathlib
import sys
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
...@@ -19,3 +19,6 @@ class MqttClient: ...@@ -19,3 +19,6 @@ class MqttClient:
def subscribe(self, topic, fun): def subscribe(self, topic, fun):
self.client.subscribe(topic) self.client.subscribe(topic)
self.client.message_callback_add(topic, fun) self.client.message_callback_add(topic, fun)
def publish(self, topic, message):
self.client.publish(topic, message)
""" """
Tool class that implement basic interaction that help to finish processes Tool class that implement basic interaction that help to finish processes
""" """
from time import sleep
import sys
import pathlib import pathlib
import sys
from time import sleep
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
......
import os import pathlib
import sys
from pexpect import pxssh from pexpect import pxssh
import sys
import pathlib
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
from tool.confi_reader import read_ssh from tool.confi_reader import read_ssh
...@@ -20,7 +18,7 @@ class Cmd: ...@@ -20,7 +18,7 @@ class Cmd:
class SSHClient: class SSHClient:
def __init__(self): def __init__(self):
self.clients = read_ssh(str(pathlib.Path(__file__).parent.resolve())+"/config.json") self.clients = read_ssh(str(pathlib.Path(__file__).parent.resolve()) + "/config.json")
def run_cmd(self, client: int, cmd: list): def run_cmd(self, client: int, cmd: list):
try: try:
......
import paramiko
import os import os
import sys
import pathlib import pathlib
import sys
import paramiko
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
from tool.confi_reader import read_ssh from tool.confi_reader import read_ssh
...@@ -11,7 +11,7 @@ from tool.confi_reader import read_ssh ...@@ -11,7 +11,7 @@ from tool.confi_reader import read_ssh
class VersionManager: class VersionManager:
def __init__(self): def __init__(self):
self.clients = read_ssh(str(pathlib.Path(__file__).parent.resolve())+"/config.json") self.clients = read_ssh(str(pathlib.Path(__file__).parent.resolve()) + "/config.json")
def update(self): def update(self):
for client in self.clients: for client in self.clients:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment