Files
sunnypilot/tools/zookeeper/enable_and_wait.py
Adeeb Shihadeh 16ec56398c add openpilot prefix to imports (#29498)
* add openpilot prefix to imports

* more

* more

* fix docs

* fix linter

* bump submodules

* fix patched tests

* update dynamic imports

* debug

* Revert "debug"

This reverts commit db5e13b9911cc74438bee123bc3430da6c31b24b.

* fix pm test
old-commit-hash: a9626f95b6
2023-08-20 20:49:55 -07:00

32 lines
634 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
import time
from socket import gethostbyname, gaierror
from openpilot.tools.zookeeper import Zookeeper
def is_online(ip):
try:
addr = gethostbyname(ip)
return (os.system(f"ping -c 1 {addr} > /dev/null") == 0)
except gaierror:
return False
if __name__ == "__main__":
z = Zookeeper()
z.set_device_power(True)
ip = str(sys.argv[1])
timeout = int(sys.argv[2])
start_time = time.time()
while not is_online(ip):
print(f"{ip} not online yet!")
if time.time() - start_time > timeout:
print("Timed out!")
raise TimeoutError()
time.sleep(1)