since #453 was fixed, mlist.last_post_at is None and time.ctime(None) is the current date and time. That too could easily be fixed like:
import time def last_post(mlist): if mlist.last_post_at: print('{}: Last post at {}'.format( mlist.display_name, time.ctime(mlist.last_post_at) )) else: print('{}: No posts'.format(mlist.display_name)) The trickier part is the Mailman 3 mailman withlist command has no option to run for all lists, so you'd need to run it something like #!/bin/sh for list in mailman lists -q; do mailman withlist -r last_post -l $list done
Thanks for the leg up on converting that from mailman2 to mailman3 much appreciated.
I found 1 issue. When I had a list that was imported, but had not done another post after being imported, the script would fail with the following error: print('{}: Last post at {}'.format( mlist.display_name, time.ctime(mlist.last_post_at) )) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'datetime.datetime' object cannot be interpreted as an integer
Made a final change to set the mlist.last_post_at to mlist.last_post_at.timestamp() and that cleared the problem.
The final form of last_post.py is:
import time
def last_post(mlist): if mlist.last_post_at: print('{}: Last post at {}'.format( mlist.display_name, time.ctime(mlist.last_post_at.timestamp()) )) else: print('{}: No posts'.format(mlist.display_name))
Don't know if this will help others, but the place I put the last_post.py file was in: /opt/mailman/venv/bin (same location as the mailman script executable).
Bryan