X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fstats.py;h=20a02b55cac3c0d4345efe5f8d4017ed5a2f02e2;hb=564395db9f6a393a894fa1b2f7ff5aefcfadd2b7;hp=bf22a7741aa70047bf81ef349f573ca66c1b4fc5;hpb=30413cf0ff7bc21b8d2b8b4346406357fe55dc19;p=dak.git diff --git a/dak/stats.py b/dak/stats.py index bf22a774..20a02b55 100755 --- a/dak/stats.py +++ b/dak/stats.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Various statistical pr0nography fun and games -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: saffron,v 1.3 2005-11-15 09:50:32 ajt Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2006 James Troup # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,8 +31,8 @@ ################################################################################ import pg, sys -import utils import apt_pkg +from daklib import utils ################################################################################ @@ -43,12 +42,12 @@ projectB = None ################################################################################ def usage(exit_code=0): - print """Usage: saffron STAT + print """Usage: dak stats MODE Print various stats. -h, --help show this help and exit. -The following STAT modes are available: +The following MODEs are available: arch-space - displays space used by each architecture pkg-nums - displays the number of packages by suite/architecture @@ -72,11 +71,11 @@ SELECT a.arch_string as Architecture, sum(f.size) def daily_install_stats(): stats = {} - file = utils.open_file("2001-11") - for line in file.readlines(): - split = line.strip().split('~') + f = utils.open_file("2001-11") + for line in f.readlines(): + split = line.strip().split('|') program = split[1] - if program != "katie": + if program != "katie" and program != "process-accepted": continue action = split[2] if action != "installing changes" and action != "installed": @@ -141,15 +140,15 @@ def number_of_packages(): q = projectB.query("SELECT id, suite_name FROM suite") suite_ql = q.getresult() for i in suite_ql: - (id, name) = i - suites[id] = name - suite_ids[name] = id + (sid, name) = i + suites[sid] = name + suite_ids[name] = sid # Build up architecture mapping q = projectB.query("SELECT id, arch_string FROM architecture") for i in q.getresult(): - (id, name) = i - arches[id] = name - arch_ids[name] = id + (aid, name) = i + arches[aid] = name + arch_ids[name] = aid # Pre-create the dictionary for suite_id in suites.keys(): d[suite_id] = {} @@ -183,7 +182,7 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""") for arch in Cnf.ValueList("Suite::%s::Architectures" % (suite)): suite_arches[suite_id][arch] = "" suite_id_list.append(suite_id) - output_list = map(lambda x: output_format(x), suite_list) + output_list = [ output_format(i) for i in suite_list ] longest_suite = longest(output_list) arch_list = arches.values() arch_list.sort() @@ -215,22 +214,22 @@ def main (): global Cnf, projectB Cnf = utils.get_conf() - Arguments = [('h',"help","Saffron::Options::Help")] + Arguments = [('h',"help","Stats::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Saffron::Options::%s" % (i)): - Cnf["Saffron::Options::%s" % (i)] = "" + if not Cnf.has_key("Stats::Options::%s" % (i)): + Cnf["Stats::Options::%s" % (i)] = "" args = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) - Options = Cnf.SubTree("Saffron::Options") + Options = Cnf.SubTree("Stats::Options") if Options["Help"]: - usage() + usage() if len(args) < 1: - utils.warn("saffron requires at least one argument") + utils.warn("dak stats requires a MODE argument") usage(1) elif len(args) > 1: - utils.warn("saffron accepts only one argument") + utils.warn("dak stats accepts only one MODE argument") usage(1) mode = args[0].lower() @@ -250,4 +249,3 @@ def main (): if __name__ == '__main__': main() -