From 13b37750aa7399b7a8f9634e7fe7f34b0197fbf8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 23 Oct 2013 18:51:25 +0200 Subject: [PATCH] implement a debug mode --- libtuer.py | 3 ++- tuerd | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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) -- 2.30.2