from fblog import *
import mailer
# Mailer module is in PyPI
# http://pypi.python.org/pypi/mailer
now = datetime.now()
day_off = timedelta(days=1,minutes=5)
last24hours = list(between(fblog(),from_time=now-day_off))
brief = '\n'.join(frequency(last24hours))
full = '\n'.join(full(last24hours))
try:
msg = mailer.Message(From="me@domain.com",
To="admin@domain.com",
Subject="Firebird Daily Report",
Body=brief,
attachments=[full],
charset="utf-8")
sender = mailer.Mailer(host="smtp.domain.com",
usr="smtp-user",
pwd="smtp-password")
sender.send(msg)
print "%s Firebird Daily Report sent" % now.date()
except Exception as e:
print "%s Can't send Firebird Daily Report\n%s" % (now.date(), e)