Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/python-wasm
Path: blob/main/python/pylang/try.py
1391 views
1
#!/usr/bin/env python3
2
3
import subprocess
4
import sys
5
import os
6
import shutil
7
8
args = sys.argv[1:]
9
source = None
10
11
cmd = ['bin/pylang']
12
13
while args:
14
if args[0] in ('-m', '-x'):
15
cmd.append(args.pop(0))
16
elif args[0] == '-f':
17
args.pop(0)
18
source = args[0]
19
cmd.append(source)
20
else:
21
break
22
23
raw = ' '.join(args).replace('\\n', '\n')
24
25
if os.path.exists('dev'):
26
shutil.rmtree('dev')
27
shutil.copytree('release', 'dev')
28
subprocess.check_call(cmd[:1] + ['self'])
29
if source:
30
p = subprocess.Popen(
31
['node', '--stack-trace-limit=1000'] + cmd)
32
else:
33
p = subprocess.Popen(
34
['node', '--stack-trace-limit=1000'] + cmd, stdin=subprocess.PIPE)
35
p.stdin.write(raw.encode('utf-8'))
36
p.stdin.close()
37
try:
38
raise SystemExit(p.wait())
39
except KeyboardInterrupt:
40
p.kill()
41
raise SystemExit(1)
42
43