syslogLevel = logging.INFO
mailLevel = logging.CRITICAL # must be "larger" than syslog level!
mailAddress = ['post+tuer'+'@'+'ralfj.de', 'vorstand@lists.hacksaar.de']
+printLevel = logging.DEBUG
# Mail logging handler
def sendeMail(subject, text, receivers, sender='sphinx@hacksaar.de', replyTo=None):
class Logger:
def __init__ (self):
self.syslog = logging.getLogger("tuerd")
- self.syslog.setLevel(syslogLevel)
+ self.syslog.setLevel(logging.DEBUG)
self.syslog.addHandler(logging.handlers.SysLogHandler(address = '/dev/log',
facility = logging.handlers.SysLogHandler.LOG_LOCAL0))
def _log (self, lvl, what):
thestr = "%s[%d]: %s" % ("tuerd", os.getpid(), what)
# console log
- print(thestr)
+ if lvl >= printLevel:
+ print(thestr)
# syslog
- self.syslog.log(lvl, thestr)
+ if lvl >= syslogLevel:
+ self.syslog.log(lvl, thestr)
# mail log
- if lvl >= mailLevel:
+ if lvl >= mailLevel and mailAddress is not None:
sendeMail('Kritischer Türfehler', what, mailAddress)
def debug(self, what):
# Timeout we wait after the switch was switched to "Closed", until we assume nobody will open the door and we just lock it
# ALso the time we wait after the door was opend, till we assume something went wrong and start nerving
-LEAVE_TIMEOUT = 4
+LEAVE_TIMEOUT = 20
# play_sound constants
SOUNDS_DIRECTORY = "/opt/tuer/sounds/"
import RPi.GPIO as GPIO
import statemachine, actor, pins, tysock, waker
from libtuer import logger
+import argparse
+# TODO: implement some arguments, e.g. --debug which does not send e-mails and prints debug stuff
# initialize GPIO stuff
GPIO.setmode(GPIO.BOARD)