-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrac.py
More file actions
40 lines (33 loc) · 944 Bytes
/
rac.py
File metadata and controls
40 lines (33 loc) · 944 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
39
40
import sys, subprocess, os, shutil
def find_python():
for exe in ("python", "python3"):
path = shutil.which(exe)
if path:
return path
return None
def resolve_file(name):
candidates = [
os.path.join("rsc_ropchain", name),
os.path.join("rsc_ropchain", name + ".rsc"),
name,
name + ".rsc"
]
for path in candidates:
if os.path.exists(path): return path
return None
if len(sys.argv) < 3:
print("Usage: python rac.py <model> <name>")
sys.exit(1)
name = sys.argv[2]
model = sys.argv[1]
file_path = resolve_file(name)
if file_path is None:
print("File not found in:")
print(" - rsc_ropchain/")
print(" - current directory")
sys.exit(1)
python_exe = find_python()
if find_python() is None:
print("Python is not installed or not in PATH.")
sys.exit(1)
subprocess.run([python_exe, "main.py", "-f", "hex", model, file_path])