-
Notifications
You must be signed in to change notification settings - Fork 1
/
start_ss.py
49 lines (39 loc) · 1.76 KB
/
start_ss.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
41
42
43
44
45
46
47
import subprocess
import sys
import os
# Change the operating system name on which device you are running this code (macos/linux)
operating_system = "macos"
# Number of Storage servers i want to start (default = 1), input provided through command line
num_of_ss: int = 1
# Provide the number of SS to start through command line otherwise the default value is 1
if len(sys.argv) >= 2:
num_of_ss = int(sys.argv[1])
# Getting the path to current working directory
cwd = os.getcwd()
if operating_system == "macos":
for i in range(num_of_ss):
os.chdir(f"SS{i + 1}") # Changing cwd to the SS folder
paths = list()
with open("accessible_paths.txt", "r") as file:
paths = file.readlines()
path_string = ""
for path in paths:
path_string += path.strip()
path_string += " "
command = f'open -a Terminal.app ss.o {path_string}' # Running the command to open new terminal window and run the .o file
subprocess.Popen(command, shell=True)
os.chdir("..") # Going back to parent directory
elif operating_system == "linux":
for i in range(num_of_ss):
os.chdir(f"SS{i + 1}") # Changing cwd to the SS folder
paths = list()
with open("accessible_paths.txt", "r") as file:
paths = file.readlines()
path_string = ""
for path in paths:
path_string += path.strip()
path_string += " "
# Running the command to open new terminal window and run the .o file
command = f'gnome-terminal -x bash -c "./ss.o {path_string}"'
subprocess.Popen(command, shell=True)
os.chdir("..") # Going back to parent directory