-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.orig
48 lines (37 loc) · 1.26 KB
/
temp.orig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#####
#####
from mod_python import apache
import utility
import cgi
import datetime
import sqlite3 as lite
from test.test_support import temp_cwd
def index(req):
conn = lite.connect("/data/gardenpi.db")
cur = conn.cursor()
cur.execute("SELECT detection_time,temperature,humidity FROM TEMPERATURE WHERE detection_time >= date('now','-25 days') ORDER BY 1 DESC")
try:
rows = cur.fetchall()
req.content_type = "text/html;charset=utf-8"
req.send_http_header()
req.write(utility.getInclude("header"))
brokeTime = "0000-00-00"
tMin = 99
tMax = 0
for row in rows:
if brokeTime != str(row[0])[0:10]:
brokeTime = str(row[0])[0:10]
req.write("<BR><B>"+brokeTime+" </B>")
if row[1] > tMax:
tMax= row[1]
if row[1] < tMin:
tMin= row[1]
req.write("<IMG SRC='images/bar.png' TITLE='"+str(int(row[1]))+" - "+str(row[0])[11:]+" ℃' WIDTH='12' HEIGHT='"+str(150*row[1]/100)+"' ALT='"+str(row[1])+"'>")
except:
req.write("Unexpected error:", sys.exc_info()[0])
#req.write("<TR><TD COLSPAN=4 ALIGN=CENTER>no temperature log available</TD></TR>")
raise
req.write("</TABLE>\n")
req.write("</P>\n")
req.write(utility.getInclude("footer"))
return ;