logger = logging.getLogger(__name__)
def parse_log():
- output = ''
+ section = Section("postfix")
logger.debug("Starting postfix section")
- output += opentag('div', 1, 'postfix', 'section')
- output += writetitle("postfix")
logger.debug("Searching through postfix logs")
messages = re.findall('.*from\=<(.*)>, size\=(\d*),.*\n.*to=<(.*)>', readlog(config.prefs['logs']['postfix']))
r = []
logger.debug("Analysing message recipients")
if (len(r) > 0):
+ rec_data = Data()
s = list(set(r)) # unique recipients
if (len(s) > 1):
- r = orderbyfreq(r)
- r = truncl(r, config.prefs['maxlist'])
- output += writedata(n + " messages sent to", r)
+ rec_data.items = r
+ rec_data.orderbyfreq()
+ rec_data.truncl(config.prefs['maxlist'])
+ rec_data.subtitle = n + " messages sent to"
else:
- output += writedata(n + " messages sent to " + r[0])
+ rec_data.subtitle = n + " messages sent to " + r[0]
+ section.append_data(rec_data)
else:
- output += writedata(n + " messages sent")
+ section.append_data(Data(subtitle=n + " messages sent"))
logger.info("Found {0} messages sent to {1} recipients".format(n, str(len(r))))
- output += writedata("total of " + size)
- output += closetag('div', 1)
+ section.append_data(Data(subtitle="Total of " + size))
logger.info("Finished postfix section")
- return output
+ return section