Files
ZonePlayer/wait_for_ports.py
T
2025-06-30 20:24:59 -05:00

30 lines
725 B
Python
Executable File

#!/usr/bin/env python3
import jack
import time
import sys
import subprocess
expected = {
"Praise:left", "Praise:right",
"Worship:left", "Worship:right",
"Instrumental:left", "Instrumental:right",
"sanctuary:in_l", "sanctuary:in_r",
"prayer:in_l", "prayer:in_r",
"Mac:in_l", "Mac:in_r"
}
client = jack.Client("waiter")
timeout = 15
deadline = time.time() + timeout
while time.time() < deadline:
current = {port.name for port in client.get_ports()}
if expected.issubset(current):
print("All JACK ports found.")
subprocess.run(["systemctl", "--system", "restart", "router.service"])
sys.exit(0)
time.sleep(0.5)
print("Timeout waiting for JACK ports.")
sys.exit(1)