def main(args): if len(args) < 3: usage = 'Usage: enterprise_stats.py <date_string> \ <output_file> <with_results> <top_count> <diagnosticTerms> \ <files> ...' print usage sys.exit(1) pywrapfile.File.Init() date_string = args[0] report_filename = args[1] with_results = ("1" == args[2]) top_count = int(args[3]) diagnostic_terms = args[4] log_files = args[5:] count = 0 last_time = time.time() stats = EnterpriseStats(date_string, top_count, with_results, diagnostic_terms) if len(log_files) > 0: for log_file in log_files: isClicklog = (log_file.find('clicklog') != -1) if isClicklog: rr = recordio.RecordReader(log_file) for buf in rr: clickEvent = ClickEvent_pb.ClickEvent(buf) stats.process_click(clickEvent) rr.Close() else: rawFp = open(log_file, 'r') line = rawFp.readline() while line: count = count + 1 try: entry = libgwslog.parse_logline(line, 'weblog') except: entry = None if entry: stats.process(entry) line = rawFp.readline() try: report_file = open(report_filename, 'w') except IOError, e: sys.exit(e)