예제 #1
0
record_file = open(options.record, 'a')
mailbox = None
try:
    for label in labels:
        if not label in include: continue
        if label in exclude: continue
        if mailbox is None:
            mailbox = ImapMailbox((server, label))
        else:
            mailbox.switch(label)
        if options.search == '':
            uids = mailbox.get_all_uids()
        else:
            uids = mailbox.search(options.search)
        for uid in uids:
            if not record.has_key("%s.%s" % (label, uid)):
                descr = "%s.%s " % (label, uid)
                if options.summary:
                    s = summary(mailbox, uid, printuid=False, printout=False)[0]
                    descr += "\t" + s[3:]
                print descr
except KeyboardInterrupt:
    print ""
except Exception, errormessage:
    if options.raise_exception: raise
    print "Program ended with exception. Run again."
    print errormessage

record_file.close()
예제 #2
0
파일: readimap.py 프로젝트: dsyang/procimap
unseen = mailbox.get_unseen_uids()
if len(unseen) == 0:
    print "No unread messages"
    sys.exit(0)
else:
    if '--check' in sys.argv:
        sys.stdout.write("%s unread message" % len(unseen))
        if len(unseen) > 1:
            sys.stdout.write("s\n")
        else:
            sys.stdout.write("\n")
        sys.exit(1)

    # display selector
    print ""
    summary(mailbox, unseen, printuid=False)
    print "\nEnter 'h' for help\n"
    while True:
        # ask for input
        sys.stdout.write("> ")
        answer = sys.stdin.readline().strip()
        try:
            if answer == '' or answer == 'q' or answer == 'exit':
                sys.exit(0)
            elif answer == 'h':
                help()
            elif answer.startswith("d") \
            and len(answer) > 1:
                index_to_delete = int(answer[1:]) - 1
                uid_to_delete = unseen[index_to_delete]
                mailbox.discard(uid_to_delete)
예제 #3
0
파일: readimap.py 프로젝트: goerz/procimap
unseen = mailbox.get_unseen_uids()
if len(unseen) == 0:
    print("No unread messages")
    sys.exit(0)
else:
    if "--check" in sys.argv:
        sys.stdout.write("%s unread message" % len(unseen))
        if len(unseen) > 1:
            sys.stdout.write("s\n")
        else:
            sys.stdout.write("\n")
        sys.exit(1)

    # display selector
    print("")
    summary(mailbox, unseen, printuid=False)
    print("\nEnter 'h' for help\n")
    while True:
        # ask for input
        sys.stdout.write("> ")
        answer = sys.stdin.readline().strip()
        try:
            if answer == "" or answer == "q" or answer == "exit":
                sys.exit(0)
            elif answer == "h":
                help()
            elif answer.startswith("d") and len(answer) > 1:
                index_to_delete = int(answer[1:]) - 1
                uid_to_delete = unseen[index_to_delete]
                mailbox.discard(uid_to_delete)
                print("Message %s deleted" % (index_to_delete + 1))