Commit cb481d003d022ac107af31c7e3f5746befd1cac8
1 parent
03f75bb1
Exists in
master
and in
1 other branch
Removed hardcoded path
Showing
1 changed file
with
11 additions
and
3 deletions
Show diff stats
src/bin/get_pkgs_inst.py
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | # | 2 | # |
3 | # get_pkgs_inst.py - get tuple (package,installation) from popcon results file | 3 | # get_pkgs_inst.py - get tuple (package,installation) from popcon results file |
4 | +# | ||
5 | +# results_file: org/popcon.debian.org/popcon-mail/results | ||
4 | 6 | ||
7 | +import sys | ||
5 | from operator import itemgetter | 8 | from operator import itemgetter |
9 | + | ||
6 | if __name__ == '__main__': | 10 | if __name__ == '__main__': |
11 | + if len(sys.argv)<2: | ||
12 | + print "Usage: get_pkgs_inst popcon_results_path" | ||
13 | + exit(1) | ||
14 | + | ||
15 | + results_path = sys.argv[1] | ||
7 | pkgs_inst = {} | 16 | pkgs_inst = {} |
8 | - with open("/root/org/popcon.debian.org/popcon-mail/results") as results: | 17 | + with open(results_path) as results: |
9 | for line in results: | 18 | for line in results: |
10 | if line.startswith("Package"): | 19 | if line.startswith("Package"): |
11 | fields = line.split() | 20 | fields = line.split() |
12 | inst = int(fields[2])+int(fields[3])+int(fields[4]) | 21 | inst = int(fields[2])+int(fields[3])+int(fields[4]) |
13 | - if inst > 20: | ||
14 | - pkgs_inst[fields[1]] = inst | 22 | + pkgs_inst[fields[1]] = inst |
15 | sorted_by_inst = sorted(pkgs_inst.items(), key=itemgetter(1)) | 23 | sorted_by_inst = sorted(pkgs_inst.items(), key=itemgetter(1)) |
16 | for pkg, inst in sorted_by_inst: | 24 | for pkg, inst in sorted_by_inst: |
17 | print pkg, inst | 25 | print pkg, inst |