From 0ebdd82b4fba0fa59dba25b6c68c295726e224a8 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 12 Sep 2014 19:46:27 +0200 Subject: Using argparse module --- jasper.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jasper.py b/jasper.py index cd51960..b02f7be 100755 --- a/jasper.py +++ b/jasper.py @@ -4,6 +4,7 @@ import sys import traceback import shutil import yaml +import argparse # Set $JASPER_HOME jasper_home = os.getenv("JASPER_HOME") @@ -19,7 +20,13 @@ from client.diagnose import Diagnostics from client import vocabcompiler, stt from client import speaker as speak from client.conversation import Conversation -if len(sys.argv) > 1 and "--local" in sys.argv[1:]: + +parser = argparse.ArgumentParser(description='Test suite for the Jasper client code.') +parser.add_argument('--local', action='store_true', help='Use text input instead of a real microphone') +parser.add_argument('--no-network-check', action='store_true', help='Disable the network connection check') +args = parser.parse_args() + +if args.local: from client.local_mic import Mic else: from client.mic import Mic @@ -92,8 +99,10 @@ if __name__ == "__main__": print " Copyright 2013 Shubhro Saha & Charlie Marsh " print "===========================================================" + speaker.say("Hello.... I am Jasper... Please wait one moment.") - testConnection() + if not args.no_network_check: + testConnection() configure() profile = yaml.safe_load(open("profile.yml", "r")) -- cgit v1.3.1