-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsetup.py
More file actions
38 lines (29 loc) · 759 Bytes
/
Copy pathsetup.py
File metadata and controls
38 lines (29 loc) · 759 Bytes
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
import os
import sys
EXE_FILE = 'export'
def kill():
os.system("ps aux | grep ython | grep %s | awk '{print $2}' | xargs kill -9" % EXE_FILE)
def setup(arg = ''):
if arg == 'kill':
kill()
return
RUN_COMMAND = "nohup python3 -u %s.py &" % EXE_FILE
try:
import yaml
with open('TELEGRAPH_TOKENS') as f:
TELEGRAPH_TOKENS = yaml.load(f, Loader=yaml.FullLoader)
except:
with open('TELEGRAPH_TOKENS', 'w') as f:
f.write(yaml.dump({}, sort_keys=True, indent=2))
kill()
if arg.startswith('debug'):
os.system(RUN_COMMAND[6:-2])
else:
os.system(RUN_COMMAND)
if 'notail' not in sys.argv:
os.system('touch nohup.out && tail -F nohup.out')
if __name__ == '__main__':
if len(sys.argv) > 1:
setup(sys.argv[1])
else:
setup('')