-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_ide.py
44 lines (37 loc) · 1.53 KB
/
run_ide.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
import os, sys, time, shutil, subprocess, glob, zipfile
from pathlib import WindowsPath
try:
model = None
for file in glob.glob("*.zip"):
print("Moving",file,"to workspace and decompressing")
model = WindowsPath(file)
zipfile.ZipFile(model).extractall('/Users/Public/tuflow/.')
os.remove(WindowsPath('/Users/Public/tuflow/run_tuflow.bat'))
except Exception as e:
print("Could not find and extract preloaded model")
try:
# read the hashed password
with open(WindowsPath('/Users/Public/caddy/hp.txt'), 'r') as f:
hpass = f.read()
# create the basic authentication file
basic_auth_contents = 'basicauth /* {\n ' + os.environ['USERNAME'] + ' ' + hpass + '\n}'
with open(WindowsPath('/Users/Public/caddy/hashpass.txt'), 'w') as f:
f.write(basic_auth_contents)
except Exception as e:
print("Failed to generate credentials file")
exit()
# start the caddy server in the background
try:
caddy_proc = subprocess.Popen(WindowsPath('/Users/Public/galileo-ide/run_caddy.bat'))
except Exception as e:
print("Problem starting Caddy Server:", e)
exit()
# start the IDE process in the background
try:
ide_proc = subprocess.Popen(WindowsPath('/Users/Public/galileo-ide/run_ide.bat'))
except Exception as e:
print("Problem starting IDE process:", e)
exit()
# perform a while loop with proc.poll() == None and tail the summary file
while (caddy_proc.poll() == None) and (ide_proc.poll() == None): # Poll returns null while process is running
time.sleep(10)