# 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"""
requests = _k1lib.imports.optionalImports("requests")
if 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")