1 #!/usr/bin/python 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 26 import datetime 27 import fileinput 28 import sys 29 import os 30 31 from an_report import * 32 33 total_by_ip = {} 34 35 ip_files = [ "%s-ip.dat" % i for i in sys.argv[2:] ] 36 ip_files = [ i for i in ip_files if os.path.exists(i) ] 37 38 for l in fileinput.input(ip_files): 39 x = l.split() 40 41 try: 42 total_by_ip[x[1]] += int(x[0]) 43 except KeyError: 44 total_by_ip[x[1]] = int(x[0]) 45 46 total_by_country = ip_to_country(total_by_ip) 47 48 report_section_begin("Summary") 49 report_cols_begin() 50 report_col_begin("l") 51 report_by_ip(total_by_ip, "all non-filelist") 52 report_col_end("l") 53 report_col_begin("r") 54 report_by_country(total_by_country, "all") 55 report_col_end("r") 56 report_cols_end() 57 report_section_end() 58