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 testing (wheezy)',
20 'sid': 'Debian unstable (sid)',
21 'hardy': 'Ubuntu 08.04 LTS "Hardy Heron" (hardy)',
22 'jaunty': 'Ubuntu 09.04 "Jaunty Jackalope" (jaunty)',
23 'karmic': 'Ubuntu 09.10 "Karmic Koala" (karmic)',
24 'lucid': 'Ubuntu 10.04 LTS "Lucid Lynx" (lucid)',
25 'maverick': 'Ubuntu 10.10 "Maverick Meerkat" (maverick)',
26 'natty': 'Ubuntu 11.04 "Natty Narwhal" (natty)',
27 'oneiric': 'Ubuntu 11.10 "Oneiric Ocelot" (oneiric)',
28 'precise': 'Ubuntu 12.04 LTS "Precise Pangolin" (precise)',
29 'quantal': 'Ubuntu 12.10 "Quantal Quetzal" (quantal)',
30 'raring': 'Ubuntu 13.04 "Raring Ringtail" (raring)',
31 'saucy': 'Ubuntu 13.10 "Saucy Salamander" (saucy)',
35 if __name__ == '__main__':
37 # get the IP, date and target release
38 # the date is truncated to a month/year combo
39 listget = re.compile(r'^([0-9.:]*) .*\[([^:]*).*GET /lists/([a-z]*)')
40 for line in fileinput.FileInput(openhook=fileinput.hook_compressed):
41 match = listget.match(line)
44 addr, date, release = match.groups()
45 if not release in releases:
46 # ignore fantasy names
48 date = datetime.strptime(date, '%d/%b/%Y')
51 date = datetime(date.year, date.month, date.day / 7 * 7 + 1)
54 date = datetime(date.year, date.month, date.day / 7 * 7)
55 # microseconds since epoch
56 date = int(time.mktime(date.timetuple()) * 1000)
57 rstats = data.setdefault(releases[release], {})
58 rtime = rstats.setdefault(date, 0)
61 data[releases[release]] = rstats
62 # determine the union of all timestamps
63 timestamps = sets.Set()
64 for codename, stats in data.iteritems():
65 timestamps.union_update(stats.keys())
66 export = [{'key': release,
67 'values': [[ts, float(data[release].setdefault(ts, 0)) / 7]
68 for ts in sorted(timestamps)]}
69 for release in sorted(data)]
70 print json.dumps(export)