-
Notifications
You must be signed in to change notification settings - Fork 3
/
cleanup.py
executable file
·40 lines (31 loc) · 1.07 KB
/
cleanup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import subprocess
import sys
import os
import configparser
from utils import sync_process, get_machine_list
if __name__ == "__main__":
pool = list()
if len(sys.argv) < 2:
print("Usage: python cleanup.py <bin>")
sys.exit(-1)
binName = sys.argv[1]
print("Clean up " + binName)
config = configparser.ConfigParser()
config.read("conf/params.ini")
workdir = config['DEFAULT']['workdir']
hostPath = os.path.join(os.getcwd(), 'conf', 'hosts')
num_machines = int(config['DEFAULT']['number_machines'])
machines = get_machine_list(hostPath)
if num_machines > len(machines):
print("Specify too many number of machines")
sys.exit(-1)
for i in range(num_machines):
command = ["ssh", machines[i], "pkill " + binName]
print(command)
pool.append(subprocess.Popen(command))
sync_process(pool)
for i in range(num_machines):
command = ["ssh", machines[i], "rm -rf " + workdir + "/temp*"]
print(command)
pool.append(subprocess.Popen(command))
sync_process(pool)