2 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
3 # vi: set ft=python sts=4 ts=4 sw=4 et:
8 from datetime import datetime
16 'etch': 'Debian GNU/Linux 4.0 (etch)',
17 'lenny': 'Debian GNU/Linux 5.0 (lenny)',
18 'squeeze': 'Debian GNU/Linux 6.0 (squeeze)',
19 'wheezy': 'Debian GNU/Linux 7.0 (wheezy)',
20 'jessie': 'Debian testing (jessie)',
21 'sid': 'Debian unstable (sid)',
22 'hardy': 'Ubuntu 08.04 LTS "Hardy Heron" (hardy)',
23 'jaunty': 'Ubuntu 09.04 "Jaunty Jackalope" (jaunty)',
24 'karmic': 'Ubuntu 09.10 "Karmic Koala" (karmic)',
25 'lucid': 'Ubuntu 10.04 LTS "Lucid Lynx" (lucid)',
26 'maverick': 'Ubuntu 10.10 "Maverick Meerkat" (maverick)',
27 'natty': 'Ubuntu 11.04 "Natty Narwhal" (natty)',
28 'oneiric': 'Ubuntu 11.10 "Oneiric Ocelot" (oneiric)',
29 'precise': 'Ubuntu 12.04 LTS "Precise Pangolin" (precise)',
30 'quantal': 'Ubuntu 12.10 "Quantal Quetzal" (quantal)',
31 'raring': 'Ubuntu 13.04 "Raring Ringtail" (raring)',
32 'saucy': 'Ubuntu 13.10 "Saucy Salamander" (saucy)',
36 if __name__ == '__main__':
38 # get the IP, date and target release
39 # the date is truncated to a month/year combo
40 listget = re.compile(r'^([0-9.:]*) .*\[([^:]*).*GET /lists/([a-z]*)')
41 for line in fileinput.FileInput(openhook=fileinput.hook_compressed):
42 match = listget.match(line)
45 addr, date, release = match.groups()
46 if not release in releases:
47 # ignore fantasy names
49 date = datetime.strptime(date, '%d/%b/%Y')
52 date = datetime(date.year, date.month, date.day / 7 * 7 + 1)
55 date = datetime(date.year, date.month, date.day / 7 * 7)
56 # microseconds since epoch
57 date = int(time.mktime(date.timetuple()) * 1000)
58 rstats = data.setdefault(releases[release], {})
59 rtime = rstats.setdefault(date, 0)
62 data[releases[release]] = rstats
63 # determine the union of all timestamps
64 timestamps = sets.Set()
65 for codename, stats in data.iteritems():
66 timestamps.union_update(stats.keys())
67 export = [{'key': release,
68 'values': [[ts, float(data[release].setdefault(ts, 0)) / 7]
69 for ts in sorted(timestamps)]}
70 for release in sorted(data)]
71 print json.dumps(export)