From 7fc87e6be91e37f2270a7c0aeb50bff9cd6a81cf Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Wed, 29 Aug 2012 10:47:20 +0200 Subject: [PATCH] Added some error handling for invalid commandline options --- n900-encode.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/n900-encode.py b/n900-encode.py index 67e07eb..2aad794 100755 --- a/n900-encode.py +++ b/n900-encode.py @@ -48,8 +48,11 @@ def main(argv): # CLI Argument Processing try: opts, args = getopt.getopt(argv, "i:o:m:v:a:t:hf", ["input=", "output=", "mpopts=", "abitrate=", "vbitrate=", "threads=", "help", "force-overwrite"]) - except getopt.GetoptError as err: - printi(str(err)) + except: + usage() + + if (len(args) != 0): + print("Error: Unsupported Arguments found!") usage() input = None @@ -256,9 +259,11 @@ def cleanup(): # Cleanup try: if (mda != None): - os.kill(mda.pid()) + if (mda.pid() != None): + os.kill(mda.pid()) if (mdv != None): - os.kill(mdv.pid()) + if (mda.pid() != None): + os.kill(mdv.pid()) finally: if (afifo != None): os.remove(afifo)