diff -r e396613bc873 -r 0e829e6275dc scripts/search-index --- a/scripts/search-index Wed Feb 11 04:04:55 2009 +0200 +++ b/scripts/search-index Wed Feb 11 04:14:22 2009 +0200 @@ -69,8 +69,8 @@ # count count += 1 - # final count - if date : + # final count? + if date and count : yield date, count def _insert_lines (index, options, channel, lines) : @@ -381,14 +381,26 @@ # use unless read from tempfile if not after : after = options.after - - print "\tUsing after = %s" % after + + if not options.quiet : + print "\tOnly including dates after %s" % after else : - print "\tIgnoring --after because we found a tempfile" + if not options.quiet : + print "\t[WARN] Ignoring --after because we found a tempfile" + + # only up to some specific date? + if options.until : + until = options.until + + if not options.quiet : + print "\tOnly including dates up to %s" % until + else : + # default to now + until = None # get lines - lines = channel.source.get_modified(mtime, after) + lines = channel.source.get_modified(mtime, after, until) # insert if not options.quiet : @@ -483,6 +495,7 @@ parser.add_option('-I', "--index", dest="index_path", help="Index database path", metavar="PATH", default="logs/index" ) parser.add_option( "--autoload-state", dest="autoload_state_path", help="Path to autoload state dir", metavar="PATH", default="logs/autoload-state" ) parser.add_option( "--after", dest="after", help="Only autoload logfiles after the given date", metavar="DATE", default=None ) + parser.add_option( "--until", dest="until", help="Only autoload logfiles up to the given date", metavar="DATE", default=None ) parser.add_option('-Z', "--timezone", dest="tz_name", help="Timezone for output", metavar="TZ", default="UTC" ) parser.add_option('-f', "--force", dest="force", help="Force dangerous operation", action="store_true" ) parser.add_option( "--create", dest="create", help="Create index database", action="store_true" ) @@ -500,9 +513,13 @@ options.tz = pytz.timezone(options.tz_name) options.formatter = config.LOG_FORMATTERS[options.formatter_name](options.tz, "%H:%M:%S", None, None) + # XXX: convert to custom types if options.after : options.after = _parse_date(options, options.after) + if options.until : + options.until = _parse_date(options, options.until) + # special-case --help if options.help : return cmd_help(options, *args)