-
Notifications
You must be signed in to change notification settings - Fork 3
/
runner.py
43 lines (33 loc) · 921 Bytes
/
runner.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
#! /usr/bin/env python3
import sys
import os
import pathlib
import importlib
import builtins
name_folder = {
"discord": "discord_talos",
"server": "website",
"twitch": "twitch_talos"
}
def main():
loc = pathlib.Path(sys.argv[0]).parent
args = sys.argv[1:]
if len(args) == 0:
print("Usage: runner.py <talos program> [program flags...]")
return 0
item = args[0]
if item not in name_folder:
print("Unrecognized program. Valid programs are:")
print(", ".join(name_folder.keys()))
return 1
# Do environment setup
del sys.argv[1]
for i in ("quit", "exit", "help", "copyright", "license", "credits"):
delattr(builtins, i)
os.chdir(loc)
# Load and execute desired program
module = name_folder[item]
talos = importlib.import_module(module)
return talos.main()
if __name__ == "__main__":
sys.exit(main())