This commit is contained in:
Daniel Langbein 2022-05-30 20:07:26 +02:00
parent 35c41c3ff2
commit 80323e25c7
7 changed files with 25 additions and 25 deletions

View File

@ -59,9 +59,9 @@ python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --upg
Note about usage of TestPyPI and `--no-deps`:
> Since TestPyPI doesnt have the same packages as the live PyPI, its possible that attempting
> Since TestPyPI doesn't have the same packages as the live PyPI, it's possible that attempting
> to install dependencies may fail or install something unexpected. While this package
> doesnt have any dependencies, its a good practice to avoid installing dependencies when
> doesn't have any dependencies, it's a good practice to avoid installing dependencies when
> using TestPyPI.
(Optionally) list installed modules:

View File

@ -3,7 +3,7 @@
[metadata]
name = de.p1st.exec_notify
version = 0.1.6
version = 0.1.7
author = Daniel Langbein
author_email = daniel@systemli.org
description = mail notification if command fails

View File

@ -4,7 +4,7 @@ from sys import argv
import socket
from typing import List
from de.p1st.exec_notify.lib import exec, config, mail, util
from de.p1st.exec_notify.lib import exec, mail, util
def main():

View File

@ -19,10 +19,10 @@ class LazyConfig:
return LazyConfig._config[section][key]
def getHostAndPort() -> Tuple[str, str]:
def getHostAndPort() -> Tuple[str, int]:
try:
return LazyConfig.get('mail', 'host'), LazyConfig.get('mail', 'port')
except Exception as e:
return LazyConfig.get('mail', 'host'), int(LazyConfig.get('mail', 'port'))
except Exception:
print(f'execNotify>> Could not read value [mail][host] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@ -31,7 +31,7 @@ def getHostAndPort() -> Tuple[str, str]:
def getPassword() -> str:
try:
return LazyConfig.get('mail', 'password')
except Exception as e:
except Exception:
print(f'execNotify>> Could not read value [mail][password] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@ -40,7 +40,7 @@ def getPassword() -> str:
def getFrom() -> str:
try:
return LazyConfig.get('mail', 'from') # used for mail login as well
except Exception as e:
except Exception:
print(f'execNotify>> Could not read value [mail][from] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@ -49,7 +49,7 @@ def getFrom() -> str:
def getTo() -> str:
try:
return LazyConfig.get('mail', 'to')
except Exception as e:
except Exception:
print(f'execNotify>> Could not read value [mail][to] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@ -58,7 +58,7 @@ def getTo() -> str:
def getMailDir() -> Path:
try:
return Path(LazyConfig.get('file', 'maildir'))
except Exception as e:
except Exception:
print(f'execNotify>> Could not read value [file][maildir] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)

View File

@ -1,7 +1,7 @@
from sys import stderr
import sys
import datetime
import smtplib, ssl
import socket
import smtplib
import ssl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
@ -22,8 +22,8 @@ def sendMailOrWriteToFile(SUBJECT: str, BODY: str, informAboutLocalMail: bool =
try:
sendMail(SUBJECT=SUBJECT, BODY=BODY)
except Exception as e:
print(f'execNotify>> Could not send mail: {e}', file=stderr)
print(f'execNotify>> Writing to file instead ...', file=stderr)
print(f'execNotify>> Could not send mail: {e}', file=sys.stderr)
print(f'execNotify>> Writing to file instead ...', file=sys.stderr)
# Instead, try to save the mail so that the user can read
# it later when connected to this computer

View File

@ -2,7 +2,7 @@
from sys import argv, stderr, stdin
import socket
from de.p1st.exec_notify.lib import exec, config, mail
from de.p1st.exec_notify.lib import mail
def main():