-
Notifications
You must be signed in to change notification settings - Fork 45
/
try
executable file
·41 lines (35 loc) · 863 Bytes
/
try
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
#!/usr/bin/env python3
import subprocess
import sys
import os
import shutil
args = sys.argv[1:]
source = None
cmd = ['bin/rapydscript']
while args:
if args[0] in ('-m', '-x'):
cmd.append(args.pop(0))
elif args[0] == '-f':
args.pop(0)
source = args[0]
cmd.append(source)
else:
break
raw = ' '.join(args).replace('\\n', '\n')
if os.path.exists('dev'):
shutil.rmtree('dev')
shutil.copytree('release', 'dev')
subprocess.check_call(cmd[:1] + ['self'])
if source:
p = subprocess.Popen(
['node', '--stack-trace-limit=1000'] + cmd)
else:
p = subprocess.Popen(
['node', '--stack-trace-limit=1000'] + cmd, stdin=subprocess.PIPE)
p.stdin.write(raw.encode('utf-8'))
p.stdin.close()
try:
raise SystemExit(p.wait())
except KeyboardInterrupt:
p.kill()
raise SystemExit(1)