diff --git a/linupdate.py b/linupdate.py index 4c7c8c0..34eacdb 100755 --- a/linupdate.py +++ b/linupdate.py @@ -33,7 +33,6 @@ def main(): try: # Handle Ctrl+C (KeyboardInterrupt) signal.signal(signal.SIGINT, signal.default_int_handler) - signal.signal(signal.SIGTERM, signal.default_int_handler) # Get current date and time todaydatetime = datetime.now() @@ -135,7 +134,7 @@ def main(): exit_code = 1 # If the user presses Ctrl+C or the script is killed, do not send an email and exit with code 2 - except (KeyboardInterrupt, SystemExit): + except KeyboardInterrupt as e: send_mail = False exit_code = 2 diff --git a/src/controllers/Args.py b/src/controllers/Args.py index 826622e..4d64bb5 100644 --- a/src/controllers/Args.py +++ b/src/controllers/Args.py @@ -169,9 +169,7 @@ def parse(self): # Catch exceptions # Either ArgsException or Exception, it will always raise an ArgsException to the main script, this to avoid sending an email when an argument error occurs - except ArgsException as e: - raise ArgsException(str(e)) - except Exception as e: + except (ArgsException, Exception) as e: raise ArgsException(str(e)) try: @@ -595,9 +593,7 @@ def parse(self): # Catch exceptions # Either ArgsException or Exception, it will always raise an ArgsException to the main script, this to avoid sending an email when an argument error occurs - except ArgsException as e: - raise ArgsException(str(e)) - except Exception as e: + except (ArgsException, Exception) as e: raise ArgsException(str(e)) @@ -849,7 +845,5 @@ def help(self): # Catch exceptions # Either ArgsException or Exception, it will always raise an ArgsException to the main script, this to avoid sending an email when an argument error occurs - except ArgsException as e: - raise ArgsException('Printing help error: ' + str(e)) - except Exception as e: + except (ArgsException, Exception) as e: raise ArgsException('Printing help error: ' + str(e))