-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwait-for-node.py
More file actions
40 lines (31 loc) · 1.17 KB
/
wait-for-node.py
File metadata and controls
40 lines (31 loc) · 1.17 KB
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 time
import sys
import os
# chdir to the current script dir
os.chdir(os.path.dirname(os.path.abspath(__file__)))
doesDev = False
def wait_for_server():
global doesDev
while True:
try:
subprocess.check_output(['curl', '-s', '-o', '/dev/null', '-w', '%{http_code}', 'http://localhost:669'])
subprocess.check_output(['curl', '-s', '-o', '/dev/null', '-w', '%{http_code}', 'http://localhost:5173' if doesDev else 'http://localhost:4173'])
break
except subprocess.CalledProcessError:
time.sleep(1)
def launch_electron():
global doesDev
electron_command = ['electron34', "./electron-init.js", '--icon', './python-side/resources/projectgdl-logo.png', '--url']
if '--update' in sys.argv:
subprocess.run(electron_command + ['http://localhost:5173/update' if doesDev else 'http://localhost:4173/update'])
else:
subprocess.run(electron_command + ['http://localhost:5173' if doesDev else 'http://localhost:4173'])
def main():
global doesDev
if '--dev' in sys.argv:
doesDev = True
wait_for_server()
launch_electron()
if __name__ == "__main__":
main()