-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (43 loc) · 1.58 KB
/
Copy pathmain.py
File metadata and controls
50 lines (43 loc) · 1.58 KB
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
import sys
import subprocess
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
def main():
# Read the current directory for files ending with .z64
files_in_current_directory = [
item
for item in os.listdir(".")
if os.path.isfile(os.path.join(".", item)) and item.endswith(".z64")
]
results = []
for f in files_in_current_directory:
print(f"Extracting from ROM file: {f}")
# Pass --called-by-main so extract.py knows it's being run from this script
cmd = [sys.executable, os.path.join(current_dir, "extract.py"), "--called-by-main", f]
try:
completed = subprocess.run(cmd, capture_output=True, text=True, check=True)
if completed.stdout:
sys.stdout.write(completed.stdout)
if completed.stderr:
sys.stderr.write(completed.stderr)
results.append((f, completed.returncode))
except KeyboardInterrupt:
raise
except subprocess.CalledProcessError as e:
if e.stdout:
sys.stdout.write(e.stdout)
if e.stderr:
sys.stderr.write(e.stderr)
if e.stderr:
sys.stderr.write(e.stderr)
print(f"Error extracting {f}, continuing...\n")
results.append((f, e.returncode))
continue
print("Finished extractions. Results:")
for f, success in results:
if success >= 100:
print(f"SUCCESS: {f}")
else:
print(f"FAILURE: {f} {success}%")
if __name__ == "__main__":
main()