summaryrefslogtreecommitdiff
path: root/tools/downloadstats
blob: c0019346f22eb403ff259281117d1626b717e5ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
# Generates download stats for all days in the given log files,
# except for the oldest and the newest day.
import sys, os, csv
import apache_reader, apache_stats

statsdir = '/data/www/pypi/local-stats/'

days = set()
records = []
for fn in sys.argv[1:]:
    for record in apache_reader.ApacheLogReader(fn, '/packages'):
        days.add((record['year'], record['month'], record['day']))
        records.append(record)

days = sorted(days)[1:-1]

class Stats(apache_stats.LocalStats):
    def _get_logs(self, logfile, files_url):
        return records
stats = Stats()
for year,month,day in days:
    stats.build_local_stats(year, month, day, None, statsdir+'days')