BAPSicle/launch_standalone.py

45 lines
1.3 KiB
Python
Raw Normal View History

2020-10-25 01:23:24 +00:00
import multiprocessing
import time
import sys
import webbrowser
2020-10-25 01:23:24 +00:00
from server import BAPSicleServer
2020-11-01 00:31:58 +00:00
def startServer():
2020-10-25 01:23:24 +00:00
# On Windows calling this function is necessary.
# Causes all kinds of loops if not present.
multiprocessing.freeze_support()
2020-11-01 00:31:58 +00:00
server = multiprocessing.Process(target=BAPSicleServer)
server.start()
2020-10-25 01:23:24 +00:00
while True:
2020-11-01 00:31:58 +00:00
time.sleep(2)
if server and server.is_alive():
pass
else:
print("Server dead. Exiting.")
sys.exit(0)
if __name__ == '__main__':
if len(sys.argv) > 1:
# We got an argument! It's probably Platypus's UI.
try:
if (sys.argv[1]) == "Start Server":
print("NOTIFICATION:Welcome to BAPSicle!")
webbrowser.open("http://localhost:13500/")
startServer()
if (sys.argv[1] == "Status"):
webbrowser.open("http://localhost:13500/status")
if (sys.argv[1] == "Config"):
webbrowser.open("http://localhost:13500/config")
if (sys.argv[1] == "Logs"):
webbrowser.open("http://localhost:13500/logs")
except Exception as e:
print("ALERT:BAPSicle failed with exception:\n", e)
sys.exit(0)
else:
startServer()