2 import RPi.GPIO as GPIO
3 import statemachine, actor, pins, tysock, waker, spaceapi
4 from libtuer import logger
8 parser = argparse.ArgumentParser(description='Run a door')
9 parser.add_argument("-d", "--debug",
10 action="store_true", dest="debug",
11 help="Don't send emails")
12 parser.add_argument("-f", "--fallback",
13 action="store_true", dest="fallback",
14 help="Fallback mode for unfunctional hardware: Depend on less sensor input")
15 args = parser.parse_args()
18 libtuer.mailAddress = []
20 logger.info("Starting in fallback mode")
22 # to avoid exceptions or getting None
26 logger.info("Starting up...")
28 # initialize GPIO stuff
29 GPIO.setmode(GPIO.BOARD)
32 the_actor = actor.Actor()
33 the_waker = waker.Waker()
34 the_api = spaceapi.SpaceApi(the_waker)
35 the_machine = statemachine.StateMachine(the_actor, the_waker, the_api, args.fallback)
36 the_socket = tysock.TySocket(the_machine)
37 the_pins = pins.PinsWatcher(the_machine)
39 # we do the socket accept thing in the main thread
42 except KeyboardInterrupt:
43 # this is what we waited for!
46 logger.info("Terminating...") # somehow this does not arrive in the syslog
49 the_waker.stop() # this one first, it "randomly" calls other threads
50 the_pins.stop() # as does this