dragonpilot - 基於 openpilot 的開源駕駛輔助系統
				
			 
			
		 
		
		
		
		
		
		
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
	
	
		
		
			
	
	
		
			
				
					
						
							|  |  |  | #!/usr/bin/env python3
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import os
 | 
					
						
							|  |  |  | import sys
 | 
					
						
							|  |  |  | import time
 | 
					
						
							|  |  |  | from tools.zookeeper import Zookeeper
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def is_online(ip):
 | 
					
						
							|  |  |  |   return (os.system(f"ping -c 1 {ip} > /dev/null") == 0)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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)
 | 
					
						
							|  |  |  | 
 |