From 2ce7450d21fafd7b487db851361437bdd9275123 Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Mon, 13 Apr 2015 18:21:15 -0500 Subject: [PATCH] Use restrict variable for weather restrictions This replaces the scale modification which messes with users using a manual watering level --- application.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application.py b/application.py index 6b28be9..0a92dda 100644 --- a/application.py +++ b/application.py @@ -72,7 +72,7 @@ def application(environ, start_response): else: fwv = '' - maxh, minh, meant, pre, pre_today, h_today, sunrise, sunset, scale, toffset = [-1, -1, -500, -1, -1, -1, -1, -1, -1, -1] + restrict, maxh, minh, meant, pre, pre_today, h_today, sunrise, sunset, scale, toffset = [0, -1, -1, -500, -1, -1, -1, -1, -1, -1, -1] eip = IP2Int(getClientAddress(environ)) @@ -237,7 +237,7 @@ def application(environ, start_response): preTotal = pre_today + pre + pre_beforeYesterday if (preTotal > 0.01): - scale = 0 + restrict = 1 except: pass @@ -253,9 +253,9 @@ def application(environ, start_response): sunset = int(((sunset +delta)%86400)/60) if of=='json' or of=='JSON': - output = '{"scale":%d, "tz":%d, "sunrise":%d, "sunset":%d, "maxh":%d, "minh":%d, "meant":%d, "pre":%f, "prec":%f, "hc":%d, "eip":%d}' % (scale, toffset, sunrise, sunset, int(maxh), int(minh), int(meant), pre, pre_today, int(h_today), eip) + output = '{"scale":%d, "restrict":%d, "tz":%d, "sunrise":%d, "sunset":%d, "maxh":%d, "minh":%d, "meant":%d, "pre":%f, "prec":%f, "hc":%d, "eip":%d}' % (scale, restrict, toffset, sunrise, sunset, int(maxh), int(minh), int(meant), pre, pre_today, int(h_today), eip) else: - output = '&scale=%d&tz=%d&sunrise=%d&sunset=%d&maxh=%d&minh=%d&meant=%d&pre=%f&prec=%f&hc=%d&eip=%d' % (scale, toffset, sunrise, sunset, int(maxh), int(minh), int(meant), pre, pre_today, int(h_today), eip) + output = '&scale=%d&restrict=%d&tz=%d&sunrise=%d&sunset=%d&maxh=%d&minh=%d&meant=%d&pre=%f&prec=%f&hc=%d&eip=%d' % (scale, restrict, toffset, sunrise, sunset, int(maxh), int(minh), int(meant), pre, pre_today, int(h_today), eip) response_headers = [('Content-type', 'text/plain'),('Content-Length', str(len(output)))] start_response(status, response_headers)