This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlauncher.py
77 lines (54 loc) · 1.86 KB
/
launcher.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# StreamX #
import subprocess
import os
print("------------------ StreamX Launcher Script 1.0 ------------------")
print("2023 StreamX Developers")
print("-----------------------------------------------------------------")
print("For help, run the \"help\" commmand")
def start():
print("Starting StreamX... Please hold")
subprocess.run(["sudo", "systemctl", "start", "streamx"])
exit("Success!")
def restart():
print("Restarting StreamX...")
subprocess.run(["sudo", "systemctl", "restart", "streamx"])
exit("Success!")
def stop():
print("Stopping StreamX...")
subprocess.run(["sudo", "systemctl", "stop", "streamx"])
exit("Success!")
def status():
subprocess.run(["systemctl", "status", "streamx"])
exit()
def install():
print("Installing StreamX... This will take a while.")
subprocess.run(["python3", "-m", "pip", "install", "-r", "requirements.txt"])
print("Successfully installed all packages!\nAttempting to start StreamX...")
start()
exit("Complete.")
def _help():
print("".join([n.lstrip() + "\n" for n in """
StreamX Launcher Script
Pretty basic but gets the job done.
-- start: Starts StreamX
-- stop: Stops StreamX
-- restart: Restarts StreamX
-- status: gives the status of StreamX.
-- install: Installs StreamX packages. WARNING: Do NOT run this after the first time.""".split("\n")]))
###################
cmds = {
"start": start,
"stop": stop,
"restart": restart,
"install": install,
"help": _help,
"status": status
}
while True:
x = input("launcher/>")
if x not in cmds:
print("Invalid command! Run \"help\" to get a list of commands.")
try:
cmds[x]()
except:
print(f"Something went wrong running {x}. This could be an installation error.\nTo reinstall the packages, run the install command.")