Beispiel #1
0
            except IgnorableException as e:
                log_failed_message(listid, "mbox", opt.mbox, ap, e)
                opstatus.failed += 1
                continue
            ap.store(conn, listid, opt.overwrite, opt.overwrite)
            purges.update(ap.purges)
        if mboxparser.returncode():
            log.error("Failed to parse mbox:")
            log.error(mboxparser.stderr_output())
            sys.exit(1)
    else:
        # Parse single message on stdin
        ap = ArchivesParserStorage()
        ap.parse(sys.stdin.buffer)
        try:
            ap.analyze(date_override=opt.force_date)
        except IgnorableException as e:
            log_failed_message(listid, "stdin", "", ap, e)
            conn.close()
            sys.exit(1)
        ap.store(conn, listid, opt.overwrite, opt.overwrite)
        purges.update(ap.purges)
        if opstatus.stored:
            log.log("Stored message with message-id %s" % ap.msgid)

    conn.commit()
    conn.close()
    opstatus.print_status()

    VarnishPurger(cfg).purge(purges)
Beispiel #2
0
        print("No bare arguments accepted")
        optparser.print_help()
        sys.exit(1)

    if not opt.msgid:
        print("Message-id must be specified")
        optparser.print_help()
        sys.exit(1)

    cfg = ConfigParser()
    cfg.read('%s/archives.ini' %
             os.path.realpath(os.path.dirname(sys.argv[0])))
    try:
        connstr = cfg.get('db', 'connstr')
    except:
        connstr = 'need_connstr'

    conn = psycopg2.connect(connstr)
    curs = conn.cursor()

    curs.execute("SELECT id, threadid FROM messages WHERE messageid=%(msgid)s",
                 {
                     'msgid': opt.msgid,
                 })
    id, threadid = curs.fetchone()

    VarnishPurger(cfg).purge([
        int(threadid),
    ])
    conn.close()
Beispiel #3
0
            laststatus = datetime.now()

    print("")

    if opt.update:
        opstatus.print_status()
        if not opt.commit:
            while True:
                print("OK to commit transaction? ")
                a = input().lower().strip()
                if a == 'y' or a == 'yes':
                    print("Ok, committing.")
                    break
                elif a == 'n' or a == 'no':
                    print("Aborting and rolling back")
                    conn.rollback()
                    sys.exit(1)
        conn.commit()
        VarnishPurger(cfg).purge(ap.purges)
    else:
        fromonlyf.close()
        f.close()
        if os.path.getsize('reparse.diffs') == 0:
            os.unlink('reparse.diffs')
        if os.path.getsize('reparse.fromonly') == 0:
            os.unlink('reparse.fromonly')

        # Just in case
        conn.rollback()
    conn.close()