def main(): """Runs the application as a service""" server = WebServer(port=8181) try: server.serve() while 1: sleep(1) except KeyboardInterrupt: server.shutdown() quit()
def main(): """Runs the application as a service""" controller = Controller() server = WebServer(port=8181, controller=controller) try: controller.run() server.serve() while 1: sleep(1) except KeyboardInterrupt: controller.stop() server.shutdown() quit()
sv.update() ultrasonic_update() cmd_update() motor_controller() hand_controller() if __name__ == '__main__': try: main() except (KeyboardInterrupt, SystemExit) as e: print(e) GPIO.cleanup() ps2.clean() motor.clean() sv.shutdown() # turn on ro sp.call(['sudo','mount','-o','remount,ro','/'], shell=False) sp.call(['sudo','mount','-o','remount,ro','/boot'], shell=False) except (OSError, Exception) as e: # I/O error or exception print(e) GPIO.cleanup() ps2.clean() motor.clean() sv.shutdown() # turn on ro sp.call(['sudo','mount','-o','remount,ro','/'], shell=False) sp.call(['sudo','mount','-o','remount,ro','/boot'], shell=False)