Exemplo n.º 1
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# tickler-mail - maildir-based email follow-up reminders (aka ticklers,
# boomerangs, etc)
#
# (c) 2014, Noah K. Tilton <*****@*****.**>, GPL

from glob import glob

from mailbox import Maildir
from utils import notify, tickle_iterator, mv

if __name__ == '__main__':

    INBOX       = glob("/home/noah*/mail/noah*@*.com/INBOX")[0]
    TICKLE_PATH = glob("/home/noah*/mail/noah*@*.com/@todo")[0]

    for T in tickle_iterator( TICKLE_PATH ):
        if T['due']:
            # mark as tickling
            msg = T['src'][T['key']]
            del msg['X-Tickler']
            msg['X-Tickler'] = T['tickle_time']
            # mark read
            msg.add_flag('S')
            # notify
            notify( msg )
            # move message to inbox
            mv(T['src'], Maildir(INBOX), msg, T['key'])
Exemplo n.º 2
0
from glob import glob

from termcolor import colored

from utils import tickle_iterator

# TODO:
# add INBOX folder, but only for messages with X-Tickler:yes

TICKLE_PATH     = glob("/home/noah*/mail/noah*@*.com/@todo")[0]
DUE_NOW_PATH    = glob("/home/noah*/mail/noah*@*.com/INBOX")[0]
INDENT          = ' ' * 4
LINE_LEN        = 102

tickles = sorted(
    [ T for T in tickle_iterator(TICKLE_PATH)   ] +
    [ T for T in tickle_iterator(DUE_NOW_PATH)  ], key=lambda d: (not d['due_in'],
                                                                  not d['due'],
                                                                  d['start_time']), reverse=True)

for T in tickles:
    msg = T['src'][T['key']]
    print colored(('-' * LINE_LEN), 'magenta')
    if T['due_in'] is not None:
        if T['due']:
            print colored('%s ago' % T['due_in'], 'red'),
        else:
            print colored('due in %s' % T['due_in'], 'green'),
    print colored('/%s' % T['boxname'], 'cyan'),
    print colored(' '.join(msg['subject'].splitlines()), 'white', attrs=['bold']),
    print colored(msg['from'], 'blue')