exit error with args parser

This commit is contained in:
Bastian Schroll 2015-04-19 19:21:35 +02:00
parent 8083339658
commit 6269a10b99

View file

@ -38,40 +38,41 @@ def log(msg, level="log"):
bos_log = open(script_path+"/log_bos.txt", "a")
bos_log.write(log_entry+"\n")
bos_log.close()
# Programm
#Clear the Logfiles
try:
script_path = os.path.dirname(os.path.abspath(__file__))
bos_log = open(script_path+"/log_bos.txt", "w")
rtl_log = open(script_path+"/log_rtl.txt", "w")
mon_log = open(script_path+"/log_mon.txt", "w")
bos_log.write("##### "+curtime()+" #####\n\n")
rtl_log.write("##### "+curtime()+" #####\n\n")
mon_log.write("##### "+curtime()+" #####\n\n")
bos_log.close()
rtl_log.close()
mon_log.close()
except:
log("cannot clear logfiles","error")
try:
#With -h or --help you get the Args help
#ArgsParser
parser = argparse.ArgumentParser(prog="boswatch.py", description="BOSWatch is a Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG", epilog="More Options you can find in the extern config.ini File in this Folder")
#parser.add_argument("-c", "--channel", help="BOS Channel you want to listen")
parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True)
parser.add_argument("-d", "--device", help="Device you want to use (Check with rtl_test)", type=int, default=0)
parser.add_argument("-e", "--error", help="Frequency-Error of your Device in PPM", type=int, default=0)
parser.add_argument("-a", "--demod", help="Demodulation Functions", choices=['FMS', 'ZVEI', 'POC512', 'POC1200', 'POC2400'], required=True, nargs="+")
parser.add_argument("-s", "--squelch", help="Level of Squelch", type=int, default=0)
parser.add_argument("-v", "--verbose", help="Shows more Information", action="store_true")
parser.add_argument("-q", "--quiet", help="Shows no Information. Only Logfiles", action="store_true")
args = parser.parse_args()
except:
log("cannot parse Args","error")
script_path = os.path.dirname(os.path.abspath(__file__))
try:
bos_log = open(script_path+"/log_bos.txt", "w")
rtl_log = open(script_path+"/log_rtl.txt", "w")
mon_log = open(script_path+"/log_mon.txt", "w")
bos_log.write("##### "+curtime()+" #####\n\n")
rtl_log.write("##### "+curtime()+" #####\n\n")
mon_log.write("##### "+curtime()+" #####\n\n")
bos_log.close()
rtl_log.close()
mon_log.close()
except:
log("cannot clear logfiles","error")
try:
#With -h or --help you get the Args help
#ArgsParser
parser = argparse.ArgumentParser(prog="boswatch.py", description="BOSWatch is a Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG", epilog="More Options you can find in the extern config.ini File in this Folder")
#parser.add_argument("-c", "--channel", help="BOS Channel you want to listen")
parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True)
parser.add_argument("-d", "--device", help="Device you want to use (Check with rtl_test)", type=int, default=0)
parser.add_argument("-e", "--error", help="Frequency-Error of your Device in PPM", type=int, default=0)
parser.add_argument("-a", "--demod", help="Demodulation Functions", choices=['FMS', 'ZVEI', 'POC512', 'POC1200', 'POC2400'], required=True, nargs="+")
parser.add_argument("-s", "--squelch", help="Level of Squelch", type=int, default=0)
parser.add_argument("-v", "--verbose", help="Shows more Information", action="store_true")
parser.add_argument("-q", "--quiet", help="Shows no Information. Only Logfiles", action="store_true")
args = parser.parse_args()
except:
log("cannot parse Args","error")
try:
#Read Data from Args, Put it into working Variables
freq = args.freq