def do_sound_check(): """ asks the user if he heard 4 clicks, returns the boolean result""" print 'Did you hear the devices switching? (enter \'y\' or \'n\' or any other key to repeat)?' response = misc_utils.get_single_char().lower() if response == 'y': return True elif response == 'n': chestfreezer_gpio.cleanup() sys.exit('There seems to be a pin connectivity problem, check your wiring. Terminating.') else: return False
def check_internet_connectivity(): print 'Checking internet connectivity...', try: urllib2.urlopen('http://www.google.com', timeout=10) # ping google do_we_have_internet = True except urllib2.URLError: do_we_have_internet = False if do_we_have_internet: print 'connection is good.' else: print '\nCould not reach the internet. If you want to proceed regardless then press \'y\', otherwise press any other key to exit.' response = misc_utils.get_single_char().lower() if response != 'y': sys.exit('Terminating.')