diff --git a/setup.cfg b/setup.cfg index 7bf6d63..8d11f3b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ [metadata] name = de.p1st.exec_notify -version = 0.1.9 +version = 0.1.10 author = Daniel Langbein author_email = daniel@systemli.org description = mail notification if command fails diff --git a/src/de/p1st/exec_notify/execNotify.py b/src/de/p1st/exec_notify/execNotify.py index b96c1de..ea62cb5 100755 --- a/src/de/p1st/exec_notify/execNotify.py +++ b/src/de/p1st/exec_notify/execNotify.py @@ -32,7 +32,10 @@ def executeCommand(command: List[str]) -> int: :return: exit code of executed command """ - exitCode, stdout, stderr = exec.execute(command) + try: + exitCode, stdout, stderr = exec.execute(command) + except Exception as e: + exitCode, stdout, stderr = 1, '', 'Caught subprocess exception: ' + str(e) prefix = '┃ ' BODY = f'┏{"━" * 19}\n' \ diff --git a/src/de/p1st/exec_notify/lib/exec.py b/src/de/p1st/exec_notify/lib/exec.py index 87b903d..a7af4d1 100644 --- a/src/de/p1st/exec_notify/lib/exec.py +++ b/src/de/p1st/exec_notify/lib/exec.py @@ -9,8 +9,9 @@ def execute(command: List[str]): Runs the given command in a subprocess and passes stdin (if given) to that process. Waits for command to complete. - :param command: A command to executed as list of words, e.g. ['echo', 'Hello world!'] + :param command: A command to executed as list of words, e.g. `['echo', 'Hello world!']` :return: (exit_code, stdout, stderr) + :raises Exception: Might throw an exception.E.g. FileNotFoundError if the executable (first element of `command`) does not exist. """ if sys.version_info.major == 3 and sys.version_info.minor < 7: