Mercurial > templog
changeset 57:cec925666c27
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 24 Jun 2012 23:48:25 +0800 |
parents | 8e897a682208 (current diff) 79761ee67134 (diff) |
children | 5100e0bdadad |
files | |
diffstat | 3 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/web/config.py Sun Jun 24 23:47:56 2012 +0800 +++ b/web/config.py Sun Jun 24 23:48:25 2012 +0800 @@ -10,8 +10,9 @@ LINE_WIDTH = 2 -SENSOR_NAMES = {'sensor_test1': "First Test"} +SENSOR_NAMES = {'sensor_28 CE B2 1A 03 00 00 99': "Wort", + 'sensor_28 CC C1 1A 03 00 00 D4': "Board"} -SENSOR_COLOURS = {} +SENSOR_COLOURS = {'Wort': 'e49222', 'Board': '028b3d'} GRAPH_FONT = "Courier"
--- a/web/log.py Sun Jun 24 23:47:56 2012 +0800 +++ b/web/log.py Sun Jun 24 23:48:25 2012 +0800 @@ -62,12 +62,15 @@ '-h', str(config.GRAPH_HEIGHT), '--slope-mode', '--border', '0', + '--y-grid', '1:1', + '--grid-dash', '1:0', + '--color', 'GRID#00000000', + '--color', 'MGRID#aaaaaa', '--color', 'BACK#ffffff', - '--alt-y-grid', '--imgformat', 'PNG'] \ + graph_args if config.GRAPH_FONT: - args += ['--font', 'DEFAULT:0:%s' % config.GRAPH_FONT] + args += ['--font', 'DEFAULT:11:%s' % config.GRAPH_FONT] print>>sys.stderr, args rrdtool.graph(*args) return tempf.read()
--- 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)