From a2464d5e7d8dd8268067a275d9df6ac8e098d788 Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:29:43 +0100 Subject: [PATCH] patch --- linupdate.py | 3 +-- src/controllers/Args.py | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) 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))