This commit is contained in:
Daniel Langbein 2022-06-01 16:12:02 +02:00
parent b53c282509
commit 3ba46f24fe
4 changed files with 14 additions and 10 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ __pycache__/
/dist/ /dist/
/src/de.p1st.exec_notify.egg-info/ /src/de.p1st.exec_notify.egg-info/
/build/

1
.idea/execNotify.iml generated
View File

@ -7,6 +7,7 @@
<excludeFolder url="file://$MODULE_DIR$/src/de_p1st_execNotify.egg-info" /> <excludeFolder url="file://$MODULE_DIR$/src/de_p1st_execNotify.egg-info" />
<excludeFolder url="file://$MODULE_DIR$/mail" /> <excludeFolder url="file://$MODULE_DIR$/mail" />
<excludeFolder url="file://$MODULE_DIR$/src/de.p1st.exec_notify.egg-info" /> <excludeFolder url="file://$MODULE_DIR$/src/de.p1st.exec_notify.egg-info" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.10 (venv-310)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.10 (venv-310)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
# print(sys.path)
from sys import argv from sys import argv
import socket import socket
from typing import List from typing import List
@ -34,7 +35,7 @@ def executeCommand(command: List[str]) -> int:
exitCode, stdout, stderr = exec.execute(command) exitCode, stdout, stderr = exec.execute(command)
prefix = '' prefix = ''
BODY = f'{""*19}\n' \ BODY = f'{"" * 19}\n' \
f'┣╸Command:\n' \ f'┣╸Command:\n' \
f'{util.appendLinePrefix(prefix, str(command))}\n' \ f'{util.appendLinePrefix(prefix, str(command))}\n' \
f'┣╸Exit Code:\n' \ f'┣╸Exit Code:\n' \
@ -43,7 +44,7 @@ def executeCommand(command: List[str]) -> int:
f'{util.appendLinePrefix(prefix, stderr)}\n' \ f'{util.appendLinePrefix(prefix, stderr)}\n' \
f'┣╸stdout:\n' \ f'┣╸stdout:\n' \
f'{util.appendLinePrefix(prefix, stdout)}\n' \ f'{util.appendLinePrefix(prefix, stdout)}\n' \
f'{""*19}' f'{"" * 19}'
print(BODY) print(BODY)
if exitCode != 0: if exitCode != 0:

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from sys import argv, stderr, stdin import sys
# print(sys.path)
import socket import socket
from de.p1st.exec_notify.lib import mail from de.p1st.exec_notify.lib import mail
@ -23,18 +24,18 @@ def main():
subj = None subj = None
hostname = socket.gethostname() hostname = socket.gethostname()
if len(argv) > 3: if len(sys.argv) > 3:
print('execNotify>> Expected at most two arguments!', file=stderr) print('execNotify>> Expected at most two arguments!', file=sys.stderr)
exit(1) exit(1)
if len(argv) == 2 or len(argv) == 3: if len(sys.argv) == 2 or len(sys.argv) == 3:
subj = argv[1] subj = sys.argv[1]
if len(argv) == 3: if len(sys.argv) == 3:
BODY = argv[2] BODY = sys.argv[2]
if subj is None: if subj is None:
subj = 'notify' subj = 'notify'
if BODY is None: if BODY is None:
BODY = stdin.read() BODY = sys.stdin.read()
SUBJECT = f'{hostname} | {subj}' SUBJECT = f'{hostname} | {subj}'
print(SUBJECT) print(SUBJECT)