Mercurial > templog
diff web/templog.py @ 57:cec925666c27
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 24 Jun 2012 23:48:25 +0800 |
parents | 79761ee67134 |
children | 62112fc2af21 |
line wrap: on
line diff
--- a/web/templog.py Sun Jun 24 23:47:56 2012 +0800 +++ b/web/templog.py Sun Jun 24 23:48:25 2012 +0800 @@ -32,11 +32,15 @@ if 'day' in request.query: start_day = datetime.datetime.strptime(request.query.day, '%Y%m%d') start = time.mktime(start_day.timetuple()) - length = int(request.query.length) * 3600 * 24 + length = int(request.query.get('length', 5)) * 3600 * 24 else: - start_hour = datetime.datetime.strptime(request.query.hour, '%Y%m%d%H') + if 'hour' in request.query: + start_hour = datetime.datetime.strptime(request.query.hour, '%Y%m%d%H') + else: + start_hour = datetime.datetime.now() - datetime.timedelta(days=1) + start = time.mktime(start_hour.timetuple()) - length = int(request.query.length) * 3600 + length = int(request.query.get('length', 36)) * 3600 response.set_header('Content-Type', 'image/png') return log.graph_png(start, length)