checkpoint: massive refactor
This commit is contained in:
@@ -5,65 +5,58 @@ import os
|
||||
|
||||
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
if PROJECT_ROOT not in sys.path:
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
from api_hook_client import ApiHookClient
|
||||
|
||||
def diag_run():
|
||||
print("Launching GUI for manual inspection + automated hooks...")
|
||||
# Use a log file for GUI output
|
||||
with open("gui_diag.log", "w") as log_file:
|
||||
gui_process = subprocess.Popen(
|
||||
[sys.executable, "gui_2.py", "--enable-test-hooks"],
|
||||
cwd=PROJECT_ROOT,
|
||||
stdout=log_file,
|
||||
stderr=log_file,
|
||||
text=True
|
||||
)
|
||||
|
||||
client = ApiHookClient()
|
||||
print("Waiting for GUI...")
|
||||
if not client.wait_for_server(timeout=10):
|
||||
print("GUI failed to start.")
|
||||
gui_process.terminate()
|
||||
return
|
||||
|
||||
# Pushing state
|
||||
track_data = {"id": "diag_track", "title": "Diagnostic Track"}
|
||||
tickets_data = [{"id": f"T{i}", "status": "todo"} for i in range(3)]
|
||||
|
||||
print("Pushing state update...")
|
||||
client.push_event("mma_state_update", {
|
||||
"status": "active",
|
||||
"active_tier": "Tier 1",
|
||||
"track": track_data,
|
||||
"tickets": tickets_data
|
||||
})
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
print("Pushing approval request...")
|
||||
client.push_event("mma_step_approval", {
|
||||
"ticket_id": "T0",
|
||||
"payload": "Get-ChildItem"
|
||||
})
|
||||
|
||||
print("\nGUI is running. Check 'gui_diag.log' for output.")
|
||||
print("I will now poll mma_status every 2 seconds. Ctrl+C to stop.")
|
||||
|
||||
try:
|
||||
start_poll = time.time()
|
||||
while time.time() - start_poll < 30:
|
||||
try:
|
||||
status = client.get_mma_status()
|
||||
print(f"[{time.strftime('%H:%M:%S')}] Status: {status.get('mma_status')}, Pending Approval: {status.get('pending_approval')}")
|
||||
except Exception as e:
|
||||
print(f"[{time.strftime('%H:%M:%S')}] Error querying status: {e}")
|
||||
time.sleep(2)
|
||||
except KeyboardInterrupt:
|
||||
print("Stopping...")
|
||||
finally:
|
||||
gui_process.terminate()
|
||||
print("Launching GUI for manual inspection + automated hooks...")
|
||||
# Use a log file for GUI output
|
||||
with open("gui_diag.log", "w") as log_file:
|
||||
gui_process = subprocess.Popen(
|
||||
[sys.executable, "gui_2.py", "--enable-test-hooks"],
|
||||
cwd=PROJECT_ROOT,
|
||||
stdout=log_file,
|
||||
stderr=log_file,
|
||||
text=True
|
||||
)
|
||||
client = ApiHookClient()
|
||||
print("Waiting for GUI...")
|
||||
if not client.wait_for_server(timeout=10):
|
||||
print("GUI failed to start.")
|
||||
gui_process.terminate()
|
||||
return
|
||||
# Pushing state
|
||||
track_data = {"id": "diag_track", "title": "Diagnostic Track"}
|
||||
tickets_data = [{"id": f"T{i}", "status": "todo"} for i in range(3)]
|
||||
print("Pushing state update...")
|
||||
client.push_event("mma_state_update", {
|
||||
"status": "active",
|
||||
"active_tier": "Tier 1",
|
||||
"track": track_data,
|
||||
"tickets": tickets_data
|
||||
})
|
||||
time.sleep(2)
|
||||
print("Pushing approval request...")
|
||||
client.push_event("mma_step_approval", {
|
||||
"ticket_id": "T0",
|
||||
"payload": "Get-ChildItem"
|
||||
})
|
||||
print("\nGUI is running. Check 'gui_diag.log' for output.")
|
||||
print("I will now poll mma_status every 2 seconds. Ctrl+C to stop.")
|
||||
try:
|
||||
start_poll = time.time()
|
||||
while time.time() - start_poll < 30:
|
||||
try:
|
||||
status = client.get_mma_status()
|
||||
print(f"[{time.strftime('%H:%M:%S')}] Status: {status.get('mma_status')}, Pending Approval: {status.get('pending_approval')}")
|
||||
except Exception as e:
|
||||
print(f"[{time.strftime('%H:%M:%S')}] Error querying status: {e}")
|
||||
time.sleep(2)
|
||||
except KeyboardInterrupt:
|
||||
print("Stopping...")
|
||||
finally:
|
||||
gui_process.terminate()
|
||||
|
||||
if __name__ == "__main__":
|
||||
diag_run()
|
||||
diag_run()
|
||||
|
||||
Reference in New Issue
Block a user