forked from hgrecco/python-sty
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunpy.py
More file actions
26 lines (21 loc) · 700 Bytes
/
Copy pathrunpy.py
File metadata and controls
26 lines (21 loc) · 700 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
# -*- coding: utf-8 -*-
import sys
try:
reload(sys).setdefaultencoding("UTF-8")
except:
pass
filename = sys.argv[1]
with open(filename[:-3] + '.tex', "w") as fout:
sys.stdout = fout
with open(filename + '.err', "w") as ferr:
with open(filename + '.rc', 'w') as frc:
with open(filename) as f:
try:
code = compile(f.read(), filename, 'exec')
exec(code, {'print': fout.write})
frc.write('0')
except Exception as e:
frc.write('1')
import traceback
ferr.write(traceback.format_exc())
raise e