From 3ba46f24fe37aa6e69350d078623cd6de058f15a Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Wed, 1 Jun 2022 16:12:02 +0200 Subject: [PATCH] minor --- .gitignore | 1 + .idea/execNotify.iml | 1 + src/de/p1st/exec_notify/execNotify.py | 5 +++-- src/de/p1st/exec_notify/notify.py | 17 +++++++++-------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index a382872..9c5e480 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__/ /dist/ /src/de.p1st.exec_notify.egg-info/ +/build/ diff --git a/.idea/execNotify.iml b/.idea/execNotify.iml index 6a763f0..bc85af0 100644 --- a/.idea/execNotify.iml +++ b/.idea/execNotify.iml @@ -7,6 +7,7 @@ + diff --git a/src/de/p1st/exec_notify/execNotify.py b/src/de/p1st/exec_notify/execNotify.py index 4b27364..b96c1de 100755 --- a/src/de/p1st/exec_notify/execNotify.py +++ b/src/de/p1st/exec_notify/execNotify.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import sys +# print(sys.path) from sys import argv import socket from typing import List @@ -34,7 +35,7 @@ def executeCommand(command: List[str]) -> int: exitCode, stdout, stderr = exec.execute(command) prefix = '┃ ' - BODY = f'┏{"━"*19}\n' \ + BODY = f'┏{"━" * 19}\n' \ f'┣╸Command:\n' \ f'{util.appendLinePrefix(prefix, str(command))}\n' \ f'┣╸Exit Code:\n' \ @@ -43,7 +44,7 @@ def executeCommand(command: List[str]) -> int: f'{util.appendLinePrefix(prefix, stderr)}\n' \ f'┣╸stdout:\n' \ f'{util.appendLinePrefix(prefix, stdout)}\n' \ - f'┗{"━"*19}' + f'┗{"━" * 19}' print(BODY) if exitCode != 0: diff --git a/src/de/p1st/exec_notify/notify.py b/src/de/p1st/exec_notify/notify.py index c3bb09b..bdcbeac 100755 --- a/src/de/p1st/exec_notify/notify.py +++ b/src/de/p1st/exec_notify/notify.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -from sys import argv, stderr, stdin +import sys +# print(sys.path) import socket from de.p1st.exec_notify.lib import mail @@ -23,18 +24,18 @@ def main(): subj = None hostname = socket.gethostname() - if len(argv) > 3: - print('execNotify>> Expected at most two arguments!', file=stderr) + if len(sys.argv) > 3: + print('execNotify>> Expected at most two arguments!', file=sys.stderr) exit(1) - if len(argv) == 2 or len(argv) == 3: - subj = argv[1] - if len(argv) == 3: - BODY = argv[2] + if len(sys.argv) == 2 or len(sys.argv) == 3: + subj = sys.argv[1] + if len(sys.argv) == 3: + BODY = sys.argv[2] if subj is None: subj = 'notify' if BODY is None: - BODY = stdin.read() + BODY = sys.stdin.read() SUBJECT = f'{hostname} | {subj}' print(SUBJECT)