internet_checker
Probably the most utilitarian piece of code I’ve ever written, this program, coded in July 2010 when I was having faulty internet problems. It repeatedly attempts to contact google.com and plays a sound when it is successful (unfortunately the sound playing only works under Windows).
import urllib.request, winsound url_to_check = "http://google.com" run_program = True while run_program: try: f = urllib.request.urlopen(url_to_check) except: continue run_program = False winsound.PlaySound("alert.wav",winsound.SND_FILENAME)