This commit is contained in:
Daniel Langbein 2022-10-18 11:50:53 +02:00
parent 3ba46f24fe
commit fc2e8094a6
3 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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' \

View File

@ -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: