Added some logging, and some further documentation

Added logging to the code, and documenting what the code is doing, not
clear with the current code.
This commit is contained in:
Jigme Datse Yli-Rasku 2024-05-29 21:37:40 -07:00
parent c0683deebb
commit f095619494
2 changed files with 25 additions and 2 deletions

View File

@ -8,3 +8,6 @@ This is our current version trying to communicate between courier and mailman3.
* First change is changing the name to match what I have on the server. * First change is changing the name to match what I have on the server.
* Second change is to have the `#!` path hopefully pointing in the right place. * Second change is to have the `#!` path hopefully pointing in the right place.
* Which I screwed up. I think I was typing in the wrong window.
* It's not failing on command line.
* Still failing, let's get some logging.

View File

@ -1,17 +1,37 @@
#!/opt/mailman/venv/bin/su python3 #!/opt/mailman/venv/bin/python3
# #
# Written by Thomas Schneider <qsuscs@qsuscs.de> # Written by Thomas Schneider <qsuscs@qsuscs.de>
# This script is placed in public domain. If this is not applicable, consider # This script is placed in public domain. If this is not applicable, consider
# it licensed under the CC-0: # it licensed under the CC-0:
# <https://creativecommons.org/publicdomain/zero/1.0/> # <https://creativecommons.org/publicdomain/zero/1.0/>
# Command Line Arguments (reverse engineered)
# $1 LMTP Port
# $2 ????
# $3 LMTP Host
# std_in message text
try: try:
import logging
import os import os
import sys import sys
import smtplib import smtplib
logger = logging.getLogger(__name__)
logging.basicConfig(filename='~/logs/courier-to-mailman.log', level=logging.INFO)
FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s'
logging.basicConfig(format=FORMAT)
logger.info('Starting Logging')
# Setup LTMP connection
lmtp_host = sys.argv[3] if len(sys.argv) > 3 else 'localhost' lmtp_host = sys.argv[3] if len(sys.argv) > 3 else 'localhost'
logger.info('lmtp_host: %s', lmtp_host)
# class smtplib.LMTP(host='', port=LMTP_PORT, local_hostname=None, source_address=None)
lmtp = smtplib.LMTP(lmtp_host, int(sys.argv[1])) lmtp = smtplib.LMTP(lmtp_host, int(sys.argv[1]))
logger.info('lmtp_port: %s', sysv.arg[1])
try: try:
# Unfortunately qmail sends to local bare LF for end line, while # Unfortunately qmail sends to local bare LF for end line, while