# HG changeset patch # User Tero Marttila # Date 1234317500 -7200 # Node ID f5f53cc0ce165966920fac6f0745302919470995 # Parent 147be2910b0266b2fc11f43cddf3a8ce709b82ab implement autoload --reset diff -r 147be2910b02 -r f5f53cc0ce16 scripts/search-index --- a/scripts/search-index Wed Feb 11 03:52:14 2009 +0200 +++ b/scripts/search-index Wed Feb 11 03:58:20 2009 +0200 @@ -256,6 +256,35 @@ # display _output_lines(options, lines) +def _autoload_reset (options, channels) : + """ + Reset old autoload state + """ + + # warn + if not options.quiet : + print "[WARN] Resetting autoload state for: %s" % ', '.join(channel.id for channel in channels) + + # iter + for channel in channels : + # statefile path + statefile_path = os.path.join(options.autoload_state_path, 'chan-%s' % channel.id) + + # is it present? + if not os.path.exists(statefile_path) : + if not options.quiet : + print "[WARN] No statefile found at %s" % statefile_path + + else : + if not options.quiet : + print "\t%s: " % channel.id, + + # remove the statefile + os.remove(statefile_path) + + if not options.quiet : + print "OK" + def cmd_autoload (options, *channel_names) : """ Automatically loads all channel logs that have not been indexed yet (by logfile mtime) @@ -270,6 +299,11 @@ else : channels = [config.LOG_CHANNELS.lookup(channel_name) for channel_name in channel_names] + + # reset autoload state? + if options.reset : + _autoload_reset(options, channels) + print # iterate channels for channel in channels : @@ -378,6 +412,11 @@ # close+delete tempfile statefile_tmp.close() os.remove(statefile_tmppath) + + print + + # done + return def cmd_help (options, *args) : """ @@ -449,6 +488,7 @@ parser.add_option( "--create", dest="create", help="Create index database", action="store_true" ) parser.add_option( "--skip-missing", dest="skip_missing", help="Skip missing logfiles", action="store_true" ) parser.add_option( "--reload", dest="reload", help="Force reload lines", action="store_true" ) + parser.add_option( "--reset", dest="reset", help="Reset old autload state", action="store_true" ) parser.add_option( "--ignore-resume", dest="ignore_resume", help="Do not try and resume interrupted autoload", action="store_true" ) parser.add_option( "--quiet", dest="quiet", help="Supress status messages", action="store_true" )