]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding properties to PostfixLogchainInfo
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 19 Mar 2024 17:30:53 +0000 (18:30 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 19 Mar 2024 17:30:53 +0000 (18:30 +0100)
lib/pp_admintools/postfix_chain.py

index 711b9de345ada21c46a35a256408930d9bdb31e1..accb56f5669a3b44003591d0883a58fe8bcd4a82 100644 (file)
@@ -25,7 +25,7 @@ from .xlate import XLATOR
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-__version__ = '0.4.0'
+__version__ = '0.4.1'
 
 LOG = logging.getLogger(__name__)
 
@@ -134,10 +134,12 @@ class PostfixLogchainInfo(FbGenericBaseObject):
         self.auth = auth
         self.client_addr = client_addr
         self.client_host = client_host
+        self.commands = commands
         self.ehlo = ehlo
         self.end = end
         self.message_id = message_id
         self.postfix_id = postfix_id
+        self.rcpt = rcpt
         self.sent_quit = sent_quit
         self.start = start
         self.starttls = starttls
@@ -247,6 +249,31 @@ class PostfixLogchainInfo(FbGenericBaseObject):
             return
         self._client_host = val
 
+    # -----------------------------------------------------------
+    @property
+    def commands(self):
+        """Return statistics about the commands in SMTP dialogue."""
+        return self._commands
+
+    @commands.setter
+    def commands(self, value):
+        if value is None:
+            self._commands = None
+            return
+
+        if isinstance(value, int):
+            self._commands = DataPair(value)
+            return
+        if isinstance(value, DataPair):
+            self._commands = copy.copy(value)
+            return
+        val = str(value).strip()
+        if val == '':
+            self._commands = None
+            return
+        else:
+            self._commands = DataPair.from_str(val)
+
     # -----------------------------------------------------------
     @property
     def duration(self):
@@ -348,6 +375,31 @@ class PostfixLogchainInfo(FbGenericBaseObject):
             return
         self._postfix_id = val
 
+    # -----------------------------------------------------------
+    @property
+    def rcpt(self):
+        """Return statistics about recipients in SMTP dialogue."""
+        return self._rcpt
+
+    @rcpt.setter
+    def rcpt(self, value):
+        if value is None:
+            self._rcpt = None
+            return
+
+        if isinstance(value, int):
+            self._rcpt = DataPair(value)
+            return
+        if isinstance(value, DataPair):
+            self._rcpt = copy.copy(value)
+            return
+        val = str(value).strip()
+        if val == '':
+            self._rcpt = None
+            return
+        else:
+            self._rcpt = DataPair.from_str(val)
+
     # -----------------------------------------------------------
     @property
     def sent_quit(self):
@@ -463,6 +515,10 @@ class PostfixLogchainInfo(FbGenericBaseObject):
             fields.append('sent_quit={!r}'.format(str(self.sent_quit)))
         if self.auth is not None:
             fields.append('auth={!r}'.format(str(self.auth)))
+        if self.commands is not None:
+            fields.append('commands={!r}'.format(str(self.commands)))
+        if self.rcpt is not None:
+            fields.append('rcpt={!r}'.format(str(self.rcpt)))
 
         if fields:
             out += ', '.join(fields)
@@ -486,11 +542,13 @@ class PostfixLogchainInfo(FbGenericBaseObject):
         res['auth'] = self.auth
         res['client_addr'] = self.client_addr
         res['client_host'] = self.client_host
+        res['commands'] = self.commands
         res['duration'] = self.duration
         res['ehlo'] = self.ehlo
         res['end'] = self.end
         res['message_id'] = self.message_id
         res['postfix_id'] = self.postfix_id
+        res['rcpt'] = self.rcpt
         res['sent_quit'] = self.sent_quit
         res['start'] = self.start
         res['starttls'] = self.starttls