]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Fixing lib/pp_admintools/handler/pflogparse.py.
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 26 Mar 2024 13:24:10 +0000 (14:24 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 26 Mar 2024 13:24:10 +0000 (14:24 +0100)
lib/pp_admintools/handler/pflogparse.py
test/test_25_postfix_logparser.py

index aa03a881632b8dcd8f49b336ceba2cfb928fce44..6206b9aee68ba2f2ed53f30ec1b10b4e8a9f31bf 100644 (file)
@@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-__version__ = '0.3.0'
+__version__ = '0.3.1'
 
 
 # =============================================================================
@@ -131,7 +131,6 @@ class PostfixLogfileParser(HandlingObject):
 
         if command == 'postfix/smtpd' and pid:
             self.eval_smtpd_line(entry)
-            return
 
         if postfix_id:
             if command == 'postfix/smtpd' and pid:
@@ -148,7 +147,7 @@ class PostfixLogfileParser(HandlingObject):
 
             m = self.re_from_addr.match(message)
             if m and postfix_id in self.chain and self.chain[postfix_id]:
-                self.logchain[postfix_id].from_address = m[1]
+                self.chain[postfix_id].from_address = m[1]
 
     # -------------------------------------------------------------------------
     def eval_smtpd_line(self, entry):
index 27fbc7386bc13176202408cf128a50e99826320a..2f3dafd4e99a0c8e02ebe20af164292da5dc200a 100755 (executable)
@@ -92,7 +92,14 @@ class TestPostfixLogparser(PpAdminToolsTestcase):
 
         LOG.debug('PostfixLogfileParser %r: {!r}'.format(parser))
 
-        with self.logfile.open('rt') as fh:
+        maillog = self.logfile
+        if 'MAILLOG' in os.environ:
+            env_maillog = Path(os.environ['MAILLOG'])
+            if env_maillog.exists() and env_maillog.is_file() and os.access(env_maillog, os.R_OK):
+                maillog = env_maillog
+
+        LOG.debug('Parsing maillog {!r} ...'.format(str(maillog)))
+        with maillog.open('rt') as fh:
             parser.parse(fh)
 
         LOG.debug('PostfixLogfileParser %s:\n{}'.format(parser))