Source code for k1lib.website
# AUTOGENERATED FILE! PLEASE DON'T EDIT
import k1lib, time
__all__ = ["beepOnAvailable"]
[docs]def beepOnAvailable(url:str, timeout=5, **kwargs):
"""Tries to connect with a url repeatedly, and if successful, plays
a beep sound"""
import requests
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")