-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMASTER.py
More file actions
82 lines (71 loc) · 2.75 KB
/
Copy pathMASTER.py
File metadata and controls
82 lines (71 loc) · 2.75 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
import os
import sys
import subprocess
from colorama import init, Fore, Style
# Initialize colorama
init()
def run_script(script_path: str, description: str) -> bool:
"""Run a Python script and return True if successful."""
try:
result = subprocess.run(
[sys.executable, script_path],
check=True,
capture_output=True,
text=True
)
print(result.stdout)
if result.stderr:
print(f"{Fore.YELLOW}Warnings:{Style.RESET_ALL}\n{result.stderr}")
print(f"\n{Fore.GREEN}✓ {description} completed successfully{Style.RESET_ALL}")
return True
except subprocess.CalledProcessError as e:
print(f"{Fore.RED}✗ Error running {description}:{Style.RESET_ALL}")
print(e.stderr)
return False
except Exception as e:
print(f"{Fore.RED}✗ Unexpected error running {description}: {str(e)}{Style.RESET_ALL}")
return False
def main():
# Print welcome banner
print("\n╭──────────────────────────────────╮")
print("│ Code Analysis Pipeline Runner │")
print("╰──────────────────────────────────╯")
# Define script paths
base_dir = os.path.dirname(os.path.abspath(__file__))
scripts = [
{
"path": os.path.join(base_dir, "main.py"),
"description": "Part 1: File Path Collection"
},
{
"path": os.path.join(base_dir, "summarize.py"),
"description": "Part 2: File Summarization"
},
{
"path": os.path.join(base_dir, "query.py"),
"description": "Part 3: Interactive Query Interface"
}
]
# Run each script in sequence
for script in scripts:
print(f"\n{Fore.YELLOW}Starting {script['description']}{Style.RESET_ALL}")
print("=" * 50)
if not os.path.exists(script["path"]):
print(f"{Fore.RED}✗ Script not found: {script['path']}{Style.RESET_ALL}")
break
success = run_script(script["path"], script["description"])
if not success:
print(f"\n{Fore.RED}Pipeline stopped due to error in {script['description']}{Style.RESET_ALL}")
break
print("=" * 50)
print("\nPipeline execution completed.")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"\n{Fore.YELLOW}Pipeline execution interrupted by user.{Style.RESET_ALL}")
sys.exit(1)
except Exception as e:
print(f"\n{Fore.RED}Unexpected error: {str(e)}{Style.RESET_ALL}")
sys.exit(1)