-
Notifications
You must be signed in to change notification settings - Fork 19
/
run.py
executable file
·67 lines (58 loc) · 1.58 KB
/
run.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
import getopt
import sys
import subprocess
import os
from ontology.compiler import Compiler
filename = None
runmode = 0
testing = False
exitstatus = 0
def deletedebugfile(strs):
'''
Deletes the files ending with the suffix
'''
d_file = filename.replace('.py', strs)
if os.path.isfile(d_file):
subprocess.call(["rm", d_file])
if __name__ == '__main__':
opts, args = getopt.getopt(sys.argv[1:], "n:m:d:t")
for op, value in opts:
if op == "-n":
filename = value
if op == "-m":
runmode = int(value)
if op == "-t":
testing = True
if filename is None:
print("Error: Filename is not set")
exit(1)
error = False
message = ""
if runmode == 1:
message = "Runmode 1. Compile file " + filename
try:
Compiler.Compile(filename)
except Exception as error:
if not testing:
print(error)
exitstatus = 1
elif runmode == 0:
message = "Runmode 0. Dump avm code message of file " + filename
try:
compiler = Compiler.Compile(filename)
compiler.DumpAsm()
except Exception as error:
if not testing:
print(error)
exitstatus = 1
if testing:
deletedebugfile('.abi.json')
deletedebugfile('.debug.json')
deletedebugfile('.Func.Map')
deletedebugfile('.avm')
deletedebugfile('.avm.str')
deletedebugfile('.warning')
else:
print(message)
exit(exitstatus)