From 0fd1ff3a057a13284b8d914b72885eb85be1599c Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 19 Mar 2024 18:30:53 +0100 Subject: [PATCH] Adding properties to PostfixLogchainInfo --- lib/pp_admintools/postfix_chain.py | 60 +++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/lib/pp_admintools/postfix_chain.py b/lib/pp_admintools/postfix_chain.py index 711b9de..accb56f 100644 --- a/lib/pp_admintools/postfix_chain.py +++ b/lib/pp_admintools/postfix_chain.py @@ -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 -- 2.39.5