From: Ralf Jung Date: Wed, 23 Oct 2013 16:51:25 +0000 (+0200) Subject: implement a debug mode X-Git-Url: https://git.ralfj.de/saartuer.git/commitdiff_plain/13b37750aa7399b7a8f9634e7fe7f34b0197fbf8?hp=-c implement a debug mode --- 13b37750aa7399b7a8f9634e7fe7f34b0197fbf8 diff --git a/libtuer.py b/libtuer.py index 097a25a..1789b90 100644 --- a/libtuer.py +++ b/libtuer.py @@ -10,7 +10,8 @@ printLevel = logging.DEBUG # Mail logging handler def sendeMail(subject, text, receivers, sender='sphinx@hacksaar.de', replyTo=None): - if not isinstance(type(receivers), list): receivers = [receivers] + assert isinstance(receivers, list) + if not len(receivers): return # nothing to do # construct content msg = email.mime.text.MIMEText(text.encode('UTF-8'), 'plain', 'UTF-8') msg['Subject'] = subject diff --git a/tuerd b/tuerd index 5c91f92..1bee788 100755 --- a/tuerd +++ b/tuerd @@ -3,7 +3,16 @@ 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 + +# Parse arguments +parser = argparse.ArgumentParser(description='Run a door') +parser.add_argument("-d", "--debug", + action="store_true", dest="debug", + help="Don't send emails") +args = parser.parse_args() +if args.debug: + import libtuer + libtuer.mailAddress = [] # initialize GPIO stuff GPIO.setmode(GPIO.BOARD)