I am writing a MailMan withlist extension to give the last post time of a list if it was before n days ago.
import sys
import time
from datetime import datetime, timedelta
from Mailman import mm_cfg
from Mailman.Errors import NotAMemberError
...
def last_post(mlist, d=0):
days_arg = {"days": d}
list_time = datetime.fromtimestamp(mlist.last_post_time)
days_ago_time = datetime.now() - timedelta(**days_arg)
if list_time <= days_ago_time:
print '%s: Last post %s' % (
mlist.real_name,
list_time
)
The trouble is I am getting the following error when I specify a day string:
TypeError: unsupported type for timedelta days component: str
I don't think day is supposed to be a string. You should pass in an int or float.