def index_mbox (fp, name, mboxpath, pos=0): def raw_message(fp): return fp.read() mbox = mymailbox.UberUnixMailbox(fp, factory=raw_message) mbox.seekp = pos listpath = name mdb = message_db.MessageDB(listpath) mdb.createTables() count = 1 while 1: msg = mbox.next() if not msg: break try: mdb.insertMessage(msg) except KeyboardInterrupt: sys.exit(1) except: handle_error.handleException("Couldn't handle msg ending at: %s" % (fp.tell())) if (count % 8000) == 0: log("flushing... (%s)" % count) mdb.flush() log("done.") count = count + 1 mdb.flush() ## write the new position in the mbox #pos = fp.tell() pos = os.stat(mboxpath).st_size mboxpos_fn = os.path.join(listpath, "mbox.pos") open(mboxpos_fn, "w").write(str(pos))
def main(argv, stdout, environ): progname = argv[0] optlist, args = getopt.getopt(argv[1:], "", ["help", "test", "debug"]) testflag = 0 if len(args) != 0: usage(progname) return lock = do_lock(DISCUSS_DATA_ROOT, "archiver.lock") global DONE #signal.signal(signal.SIGTERM, handleSignal) log("archiver: start") try: while not DONE: try: archive_dirs() except: handle_error.handleException("Archiver Error") if DONE: break # tlog("sleeping") time.sleep(10) finally: os.unlink(os.path.join(DISCUSS_DATA_ROOT, "archiver.lock"))
SHOULD_DISPLAY = 0 except Redirected: # catch redirect exceptions SHOULD_DISPLAY = 0 except DisplayError, num: ncgi.hdf.setValue("Query.error", str(num)) if self._error_template: ncgi.hdf.setValue("Content", self._error_template) else: DISPLAY_ERROR = 1 except: SHOULD_DISPLAY = 0 DISPLAY_ERROR = 1 from clearsilver import handle_error handle_error.handleException("Display Failed!") ERROR_MESSAGE = handle_error.exceptionString() if DISPLAY_ERROR: print "Content-Type: text/html\n\n" # print the page print "<H1> Error in Page </H1>" print "A copy of this error report has been submitted to the developers. " print "The details of the error report are below." print "<PRE>" print neo_cgi.htmlEscape(ERROR_MESSAGE) print "</PRE>\n"