[Mailman-Users] bin/arch : ctime
I rebuilt, not long ago, the archives of a particular mailinglist, and the html files' atime/ctime/mtime were all changed to the time of the rebuild. The search facilities I'm using, on the same machine- glimpseindex and swish-e - by default use the ctime or mtime to return results, which isn't very convenient when searching by Date:. Has anybody ever written a script that would rebuild the html message archives that would also modify the file ctime/mtime back to the date of the message, as retrieved from the list's mbox file? thanks in advance. -- Rob Lingelbach r...@colorist.org -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Users] bin/arch : ctime
Rob Lingelbach wrote: Has anybody ever written a script that would rebuild the html message archives that would also modify the file ctime/mtime back to the date of the message, as retrieved from the list's mbox file? This script --- import os import re import time import os.path BASE = '/usr/local/mailman/archives/private/listname' NRE = re.compile(r'^\d+.html$') DRE = re.compile(r'^\s*I([^]*)/I\s*$') def process_file(pname): for line in open(pname): mo = DRE.match(line) if mo: try: ptime = time.strptime(mo.group(1), '%a %b %d %H:%M:%S %Z %Y') except ValueError: next ptime = time.mktime(ptime) os.utime(pname, (ptime, ptime)) break for dir, dirnames, filenames in os.walk(BASE): for fname in filenames: if NRE.match(fname): process_file(os.path.join(dir, fname)) --- will change atime and mtime for all the nn.html files subordinate to the BASE directory to the time parsed from the line IDay Mmm dd hh:mm:ss TZ /I in the file. It only changes atime and mtime to that time. ctime is changed to the time that it runs. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Users] bin/arch : ctime
On Oct 8, 2009, at 6:30 PM, Mark Sapiro wrote: will change atime and mtime for all the nn.html files subordinate to the BASE directory to the time parsed from the line thank you very much, just what was needed. Rob -- Rob Lingelbach r...@colorist.org -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Users] bin/arch : ctime
Mark Sapiro wrote: This script --- [...] try: ptime = time.strptime(mo.group(1), '%a %b %d %H:%M:%S %Z %Y') except ValueError: next [...] Ooops. That should be except ValueError: continue Also, a somewhat improved version can be found at http://www.msapiro.net/scripts/update_archive_mtime (mirrored at http://fog.ccsf.cc.ca.us/~msapiro/scripts/update_archive_mtime). -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Users] bin/arch : ctime
On Oct 8, 2009, at 8:11 PM, Mark Sapiro wrote: Mark Sapiro wrote: This script --- [...] try: ptime = time.strptime(mo.group(1), '%a %b %d %H:%M:%S %Z %Y') except ValueError: next [...] Ooops. That should be except ValueError: continue funny thing is, it worked, on a very minimal directory that I just ran a test on: before running script: ro...@soho89-16-222-12 0:08 pts/1 /var/www/html/mailman/archives/ private/mfrs/2009-September# stat 00.html File: `00.html' Size: 3283Blocks: 16 IO Block: 4096 regular file Device: fd03h/64771dInode: 26613721Links: 1 Access: (0664/-rw-rw-r--) Uid: (0/root) Gid: ( 41/ mailman) Access: 2009-10-09 00:00:59.0 +0100 Modify: 2009-10-08 20:29:41.0 +0100 Change: 2009-10-08 20:29:41.0 +0100 and after running: ro...@soho89-16-222-12 0:10 pts/1 /var/www/html/mailman/archives/ private/mfrs/2009-September# stat 00.html File: `00.html' Size: 3283Blocks: 16 IO Block: 4096 regular file Device: fd03h/64771dInode: 26613721Links: 1 Access: (0664/-rw-rw-r--) Uid: (0/root) Gid: ( 41/ mailman) Access: 2009-09-02 00:47:38.0 +0100 Modify: 2009-09-02 00:47:38.0 +0100 Change: 2009-10-09 00:10:29.0 +0100 and the one invocation also took care of another message.html file. But I'll make the change and test it again, and look at the more complete version as well, before I start using it on the 60k message files I need it to work on. -- Rob Lingelbach r...@colorist.org -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Users] bin/arch : ctime
Rob Lingelbach wrote: On Oct 8, 2009, at 8:11 PM, Mark Sapiro wrote: Mark Sapiro wrote: This script --- [...] try: ptime = time.strptime(mo.group(1), '%a %b %d %H:%M:%S %Z %Y') except ValueError: next [...] Ooops. That should be except ValueError: continue funny thing is, it worked, on a very minimal directory that I just ran a test on: It will work as long as it doesn't hit a I.../I line that doesn't contain a date matching the '%a %b %d %H:%M:%S %Z %Y' format. In fact, that is one of those things that won't happen as long as the message files are all well formed, but is there in order to keep looking in case it does. Python doesn't care that the name 'next' is undefined until it actually tries to execute it. -- Mark Sapiro m...@msapiro.netThe highway is for gamblers, San Francisco Bay Area, Californiabetter use your sense - B. Dylan -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Users] bin/arch : ctime
On Oct 8, 2009, at 8:28 PM, Mark Sapiro wrote: files are all well formed, but is there in order to keep looking in case it does. Python doesn't care that the name 'next' is undefined until it actually tries to execute it. There's a vortex with python in the center, me on the fringe. -- Rob Lingelbach r...@colorist.org -- Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9