-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelive.py
47 lines (41 loc) · 1.3 KB
/
relive.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
import argparse
import sys
import os
parser = argparse.ArgumentParser(description="Live view of a program, instant reload of a program")
parser.add_argument("-run", required=True, help="Used as; APPNAME:RUNTYPE:STATE, required=True.")
args = parser.parse_args(sys.argv[1:])
#args.run => Gives the components based of the argparsers libary, via Namespace class
rn = []
appstr = ""
runtime = "0"
for i in args.run.split(":"):
rn.append(i)
if len(rn) >> 2:
print("[ERROR] You cannot pass more than three arguments to -run, please try again as: APPNAME:RUNTYPE:STATE")
exit()
for i in range(len(rn)):
#1 => get app
#2 => detect runtype
#3 => check if state is recogniseable.
if i == 0:
a = rn[i]
with open(f"{a}.py", "r") as b:
appstr = b.read()
if i == 1:
a = rn[i]
if a == "live":
runtime = a
if i == 2:
a = rn[i]
if a == "full":
continue
else:
print("[ERROR] State is not recognisable; did you mean full or vairous (Currently, only full allowed.)")
exit()
exec(appstr)
while 1:
appstr_save = appstr
appstr = open(f"{rn[0]}.py", "r").read()
if appstr != appstr_save:
os.system("cls")
exec(appstr)