X-Git-Url: https://git.madduck.net/etc/mailfilter.git/blobdiff_plain/0a76b0032d4004450bee10eded1a8bdb79042c22..5950d5c4e05d47338e97a80dfa0909bf9c870ee5:/bin/process-tickler diff --git a/bin/process-tickler b/bin/process-tickler deleted file mode 100755 index 28b6c5e..0000000 --- a/bin/process-tickler +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python2.5 -# -*- coding: utf-8 -*- -# -# process-tickler – process message in tickler maildir -# -# Copyright © martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# - -import mailbox -import os -import sys -import time - -HOME = os.getenv('HOME') -MAILDIR = os.path.join(HOME, '.maildir') -TICKLER_DIR = os.path.join(MAILDIR, '.tickler') -DEST_DIR = os.path.join(MAILDIR, '.resubmit') - -tmd = mailbox.Maildir(TICKLER_DIR) -dmd = mailbox.Maildir(DEST_DIR) -msgids = dict() - -def resubmit(key): - msg = tmd.get_message(key) - print >>sys.stdout, 'I: resubmit message %s' % key - if msg.has_key('X-Tickle-Delivered'): - msg.replace_header('X-Tickle-Delivered', time.strftime('%c')) - else: - msg.add_header('X-Tickle-Delivered', time.strftime('%c')) - dmd.add(msg) - tmd.discard(key) - -for key, msg in tmd.iteritems(): - msgid = msg.get('Message-Id') - if msgid is None: - print >>sys.stderr, 'W: message without ID: ' + key - resubmit(key) - - tickle = msg.get('X-Tickle') - if tickle is None: - print >>sys.stderr, 'W: message without tickle information: ' + msgid - resubmit(key) - - if msgids.get(msgid, None) is None: - msgids[msgid] = list() - msgids[msgid].append((int(tickle.split(' ', 1)[0]), key, msg)) - -for msgid, msgs in msgids.iteritems(): - msgs.sort() - prev_tickle = None - for tickle, key, msg in msgs: - if tickle == prev_tickle: - print >>sys.stderr, 'I: discarding duplicate %s of message %s' % (key, msgid) - tmd.discard(key) - continue - prev_tickle = tickle - - t = time.time() - if t >= tickle: - resubmit(key) - else: - print >>sys.stdout, 'I: message %s still has %d seconds' % (key, - int(tickle - t))