Mercurial > templog
changeset 581:b4d6f1ae0b9e
make overshoot_factor floating point
add a proper error message for noparamsyet
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 29 Nov 2015 09:30:36 +0800 |
parents | 329e65ea1edc |
children | cebec9b40ad2 |
files | web/log.py web/templog.py web/views/noparamsyet.tpl web/views/top.tpl |
diffstat | 4 files changed, 35 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/web/log.py Tue Nov 17 22:24:28 2015 +0800 +++ b/web/log.py Sun Nov 29 09:30:36 2015 +0800 @@ -51,8 +51,6 @@ 'DS:temp:GAUGE:600:-100:500', 'RRA:AVERAGE:0.5:1:1051200'] - print>>sys.stderr, sensor_rrd_path(sensor_id) - rrdtool.create(sensor_rrd_path(sensor_id), '--start', 'now-60d', *args) @@ -143,8 +141,7 @@ sensor_lines.sort(key = lambda (legend, line): "Wort" in legend) graph_args += (line for (legend, line) in sensor_lines) - print>>sys.stderr, '\n'.join(graph_args) - + #print>>sys.stderr, '\n'.join(graph_args) end = int(start+length) start = int(start) @@ -289,11 +286,12 @@ debugf.write("Updated sensors in %.2f secs\n" % timedelta) debugf.flush() +# types used here define the type of a field _FIELD_DEFAULTS = { 'fridge_setpoint': 16.0, 'fridge_difference': 0.2, 'overshoot_delay': 720, # 12 minutes - 'overshoot_factor': 1, # ºC + 'overshoot_factor': 1.0, # ºC 'disabled': False, 'nowort': True, 'fridge_range_lower': 3, @@ -301,10 +299,14 @@ } def get_params(): + """ Can return None if there aren't any parameters yet, + otherwise returns the parameter list """ r = [] vals = read_current_params() + if not vals: + return None for k, v in _FIELD_DEFAULTS.iteritems(): n = {'name': k, 'value': type(v)(vals[k])}
--- a/web/templog.py Tue Nov 17 22:24:28 2015 +0800 +++ b/web/templog.py Sun Nov 29 09:30:36 2015 +0800 @@ -94,8 +94,13 @@ def set(): allowed = ["false", "true"][secure.check_user_hash(config.ALLOWED_USERS)] response.set_header('Cache-Control', 'no-cache') + inline_data = log.get_params() + if not inline_data: + response.status = 503 # Service Unavailable + return bottle.template('noparamsyet') + return bottle.template('set', - inline_data = log.get_params(), + inline_data = inline_data, csrf_blob = secure.get_csrf_blob(), allowed = allowed)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/views/noparamsyet.tpl Sun Nov 29 09:30:36 2015 +0800 @@ -0,0 +1,21 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +<head> +<title>Try again soon</title> +<meta name="viewport" content="width=device-width"> +<style type="text/css"> + body { + font-family: monospace; + text-align: center; + } +</style> +</head> +<body> +<p> +The templog fridge client hasn't sent its current settings to the server yet. +</p> +<p> +Try again in a minute or two. +</p> +</body> +</html>
--- a/web/views/top.tpl Tue Nov 17 22:24:28 2015 +0800 +++ b/web/views/top.tpl Sun Nov 29 09:30:36 2015 +0800 @@ -3,7 +3,7 @@ <head> <title>Wort Temperature Log</title> <meta name="viewport" content="width=device-width"> -<style type="text/css"><!-- +<style type="text/css"> span.no_selection { -webkit-user-select: none; // webkit (safari, chrome) browsers -moz-user-select: none; // mozilla browsers @@ -19,7 +19,6 @@ width: 100%; max-width: {{graphwidth}}px; } -//--> </style> <title></title> </head>