# AUTOGENERATED FILE! PLEASE DON'T EDIT
import k1lib as _k1lib, time as _time
[docs]def beepOnAvailable(url:str, timeout=5, **kwargs):
"""Tries to connect with a url repeatedly, and if successful, plays
a beep sound"""
if (requests := _k1lib.imports.OptionalImports("requests")) is None:
raise ImportError("Module requests not found")
try:
while True:
_time.sleep(1)
successful = False
try:
if requests.get(url, timeout=timeout, **kwargs).ok:
successful = True
except: pass
if successful:
_k1lib.beep()
break
except KeyboardInterrupt: print("Still not available")