def run(): """ call to web.py run(), starts the web stuff """ try: app.run() except KeyboardInterrupt: print 'Interrupted, shutting down...' # # stop threads, etc? import hardware.chestfreezer_gpio as gpio gpio.cleanup() sys.exit("Goodbye!")
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 start_web_interface(server_type = "paste"): """ starts the bottle.py server """ print 'Starting web interface...\n' api.start(server_type) if __name__ == "__main__": check_and_init_database() check_hardware() check_internet_connectivity() start_threads() start_web_interface() try: while True: pass except KeyboardInterrupt: print '\nInterrupted, shutting down...' # stop threads, cleanup, etc? normal_boolean_state = configuration.normal_relay_state() == 'open' brew_logic._set_heater(normal_boolean_state) print 'Heater returned to default state...' brew_logic._set_freezer(normal_boolean_state) print 'Freezer returned to default state...' chestfreezer_gpio.cleanup() print 'Goodbye!' os._exit(0) except Exception as e: print 'Exception: ' + str(e)
def test_cleanup(self): chestfreezer_gpio.GPIO.cleanup = Mock() chestfreezer_gpio.cleanup() chestfreezer_gpio.GPIO.cleanup.assert_called_once_with() # @UndefinedVariable