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
15 'etch': 'Debian GNU/Linux 4.0 (etch)',
16 'lenny': 'Debian GNU/Linux 5.0 (lenny)',
17 'squeeze': 'Debian GNU/Linux 6.0 (squeeze)',
18 'wheezy': 'Debian GNU/Linux 7.0 (wheezy)',
19 'jessie': 'Debian testing (jessie)',
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)',
32 'trusty': 'Ubuntu 14.04 "Trusty Tahr" (trusty)',
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
65 for codename, stats in data.iteritems():
66 timestamps.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)