From 8eb16c14549d6483e96cefa865633b1b0e0542ba Mon Sep 17 00:00:00 2001 From: ademant Date: Tue, 20 Aug 2019 05:23:30 +0200 Subject: [PATCH] new subpage for daily diagram --- pyweb.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/pyweb.py b/pyweb.py index b3e9a85..79bc1a2 100755 --- a/pyweb.py +++ b/pyweb.py @@ -312,19 +312,28 @@ def show_graph(mid,kind): mydb=pymysql.connect(read_default_file="~/.my.cnf",database="rasolar") mycursor=mydb.cursor() print(str(time.time()-starttime)+' sql open') - mycursor.execute('select ((select max(time) from '+sqltable+')-'+sqltable+'.time)/6400000 as time,'+sqltable+'.value/1000 as value from '+sqltable+' where id=%s order by time',str(mid)) - row=numpy.array(mycursor.fetchall()) - print(str(time.time()-starttime)+' sql fetched') - mycursor.close() - mydb.close() - print(str(time.time()-starttime)+' sql closed') - plt.figure(figsize=[6,8]) - plt.plot(row[:,0],row[:,1]) - print(str(time.time()-starttime)+' picture') - plt.savefig("svg/"+mid+".svg") - print(str(time.time()-starttime)+' saved') - if len(row)>0: - return template('verlauf.tpl',measdata=row,mid=mid) + nrow=mycursor.execute('select ((select max(time) from '+sqltable+')-'+sqltable+'.time)/6400000 as time,'+sqltable+'.value/1000 as value from '+sqltable+' where id=%s order by time',str(mid)) + if (nrow>0): + row=numpy.array(mycursor.fetchall()) + print(str(time.time()-starttime)+' sql fetched') + mycursor.close() + mydb.close() + print(str(time.time()-starttime)+' sql closed') + plt.figure(figsize=[6,8]) + plt.plot(row[:,0],row[:,1]) + print(str(time.time()-starttime)+' picture') + plt.savefig("svg/"+mid+".svg") + print(str(time.time()-starttime)+' saved') + if len(row)>0: + return template('verlauf.tpl',measdata=row,mid=mid) + else: + return ''' + + Keine Daten + +

Die Daten verstecken sich.

+ + ''' @app.post('/data/')