fix versioned depends lines
[enigma2-plugins.git] / fancontrol2 / src / FC2webSite.py
1 # -*- coding: utf-8 -*-
2 from twisted.web import resource, http
3 from globals import *
4 from plugin import *
5 from Sensors import sensors
6 from __init__ import _
7 from Components.config import configfile, config
8
9 import os
10 import datetime
11
12 ########################################################
13 class FC2web(resource.Resource):
14     
15         title = "FanControl2 Webinterface"
16         isLeaf = False
17    
18         def render(self, req):
19                 req.setHeader('Content-type', 'text/html')
20                 req.setHeader('charset', 'UTF-8')
21
22                 """ rendering server response """
23                 command = req.args.get("cmd",None)
24
25                 html = "<html>"
26                 html += "<head>\n"
27                 html += "<meta http-equiv=\"Content-Language\" content=\"de\">\n"
28                 html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n"
29                 html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n"
30                 html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />\n"
31                 html += "<meta http-equiv=\"expires\" content=\"0\">\n"
32                 html += "<meta http-equiv=\"refresh\" content=\"20\">\n"
33                 html += "<title>Fan Control 2 - Info</title>\n"
34                 html += "</head>"
35                 html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
36                 html += "<form method=\"POST\" action=\"--WEBBOT-SELF--\">\n"
37                 html += "<table border=\"1\" width=\"500\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\" cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
38                 html += "<p align=\"center\"><img border=\"0\" src=\"/fancontrol/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
39                 html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Info</b></font></p>\n"
40                 html += "</td><td bgcolor=\"#000000\">\n"
41                 html += "<p align=\"right\">"
42                 html += BoxStatus()
43                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
44                         html += "<a href=\"/fancontrol/chart\"><img border=\"0\" src=\"/fancontrol/FC2Chart.png\" width=\"100\" height=\"40\"></a>\n"
45                 html += "<a href=\"/fancontrol/log\"><img border=\"0\" src=\"/fancontrol/FC2Setup.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
46                 html += "<table border=\"1\" width=\"500\" id=\"table1\">\n"
47                 html += "<tr>\n"
48                 html += "<td>%s: <b><font color=\"#FFCC00\">%4.1f C</font></b></td>\n" % (_("Temperature"),FC2werte[0])
49                 html += "<td>%s: <font color=\"#FFCC00\"><b>%4d rpm</b></font></td>\n" % (_("Speed"),FC2werte[1])
50                 html += "<td>%s: <font color=\"#FFCC00\"><b>%03d</b></font></td>\n" % (_("Voltage"),FC2werte[2])
51                 html += "<td>PWM: <font color=\"#FFCC00\"><b>%03d</b></font></td>\n" % FC2werte[3]
52                 html += "</tr>\n"
53                 html += "</table>\n"
54
55                 html += "<table border=\"1\" width=\"500\">\n"
56                 html += "<tr>\n"
57                 html += "<td>%s C</td>\n" % _("Sensors")
58                 templist = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)
59                 tempcount = len(templist)
60                 for count in range(tempcount):
61                         html += "<td><font color=\"#FFCC00\">%d</font></td>" % sensors.getSensorValue(count)
62                 if FC2werte[4] > 0:
63                         html += "<td><font size=\"1\">HDD </font><font color=\"#FFCC00\">%d</font></td>\n" % FC2werte[4]
64                 html += "</tr>\n"
65                 html += "</table>\n"
66
67                 html += "<table border=\"1\" width=\"500\">\n"
68                 html += "<tr>\n"
69                 for count in range(0,12):
70                         tmp = ("<BR>-" if FC2stunde[count] == "-" else FC2stunde[count])
71                         html +="<td><p align=\"center\"><font size=\"1\">%02d:00<br><font color=\"#FFCC00\">%s</font></font></td>\n" % (count,tmp)
72                 html += "</tr><tr>\n"
73                 for count in range(12,24):
74                         tmp = ("<BR>-" if FC2stunde[count] == "-" else FC2stunde[count])
75                         html +="<td><p align=\"center\"><font size=\"1\">%02d:00<br><font color=\"#FFCC00\">%s</font></font></td>\n" % (count,tmp)
76                 html += "</tr></table>\n"
77
78                 html += "<script type=\"text/javascript\">\n"
79                 html += "function doLogWrite() {\n"
80                 html += "var iFrameWin = window.myIFrameName;\n"
81                 html += "iFrameWin.document.write('<html><head><title>FC2 Log Window</title></head><body bgcolor=\"#D3D3D3\">');\n"
82                 html += "iFrameWin.document.write('<font size=\"-1\">');\n"
83                 for L in FC2Log:
84                         html += "iFrameWin.document.write('" + L + "<br>');\n"
85                 html += "iFrameWin.document.write('</font>');\n"
86                 html += "iFrameWin.document.write('</body></html>');\n"
87                 html += "iFrameWin.document.close();\n"
88                 html += "}\n"
89                 html += "</script>\n"
90                 html += "<iframe id=\"myIFrameId\" name=\"myIFrameName\" width=\"500\" height=\"320\" marginwidth=\"5\" vspace=\"2\" marginheight=\"5\" frameborder=\"1\" scrolling=\"auto\"></iframe>\n"
91                 html += "<script>doLogWrite();\n"
92                 html += "myIFrameName.document.body.scrollTop = myIFrameName.document.body.scrollHeight*100;\n" 
93                 html += "</script>\n"
94
95                 html += "<table border=\"1\" width=\"500\">\n"
96                 html += "<tr>\n"
97                 html += "<td>Version: %s </td>\n" % Version
98                 html += "<td>Settings: %s-%s C</td>\n" % (config.plugins.FanControl.temp.value,config.plugins.FanControl.tempmax.value)
99                 html += "<td>%s-%s rpm</td>\n" % (config.plugins.FanControl.minRPM.value,config.plugins.FanControl.maxRPM.value)
100                 html += "</tr>\n"
101                 html += "</table>\n"
102                 html += "</body>\n"
103                 html += "</html>\n"
104
105                 html += "</form>\n"
106
107                 return html
108
109 ##########################################################
110 class FC2webLog(resource.Resource):
111     
112         title = "FanControl2 Webinterface"
113         isLeaf = True
114
115         def render(self, req):
116                 command = req.args.get("cmd",None)
117                 html = ""
118                 if command is None:
119                         req.setHeader('Content-type', 'text/html')
120                         req.setHeader('charset', 'UTF-8')
121
122                         """ rendering server response """
123
124                         html = "<html>"
125                         html += "<head>"
126                         html += "<meta http-equiv=\"Content-Language\" content=\"de\">"
127                         html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
128                         html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />"
129                         html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />"
130                         html += "<meta http-equiv=\"expires\" content=\"0\">"
131                         html += "<meta http-equiv=\"refresh\" content=\"30\">"
132                         html += "<title>Fan Control 2 - Logging</title>"
133                         html += "</head>"
134                         html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
135                         html += "<table border=\"1\" width=\"500\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\" cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
136                         html += "<p align=\"center\"><img border=\"0\" src=\"/fancontrol/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
137                         html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Logging</b></font></p>\n"
138                         html += "</td><td bgcolor=\"#000000\">\n"
139                         html += "<p align=\"right\">"
140                         html += BoxStatus()
141                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
142                                 html += "<a href=\"/fancontrol/chart\"><img border=\"0\" src=\"/fancontrol/FC2Chart.png\" width=\"100\" height=\"40\"></a>\n"
143                         html += "<a href=\"/fancontrol\"><img border=\"0\" src=\"/fancontrol/FC2Info.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
144
145                         html += "<table border=\"1\" width=\"500\">"
146                         html += "<tr><td width=\"50%\" align=\"center\" valign=\"top\">Data Logging "
147                         if config.plugins.FanControl.EnableDataLog.value:
148                                 html += "<font color=\"#00FF00\">%s</font>" % _("active")
149                                 html += "<form method=\"GET\">"
150                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"dataenable\">"
151                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn off")
152                                 html += "</form>"
153                         else:
154                                 html += "<font color=\"#FF0000\">%s</font>" % _("not active")
155                                 html += "<form method=\"GET\">"
156                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"dataenable\">"
157                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn on")
158                                 html += "</form>"
159                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
160                                 s = os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv")
161                                 if int(s.st_size/1024) == 0:
162                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size), "")
163                                 else:
164                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size/1024), "k")
165                                 s = os.statvfs(config.plugins.FanControl.LogPath.value)
166                                 html += "<BR>" + _("Disk free : %d MByte") % (int(s.f_bsize * s.f_bavail / 1024 / 1024))
167                                 html += "<form method=\"GET\">"
168                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"data\">"
169                                 html += "<input type=\"submit\" value=\"%s\">" % _("Download")
170                                 html += "</form>"
171                                 html += "<form method=\"GET\">"
172                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"datadel\">"
173                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete")
174                                 html += "</form>"
175                                 html += "<form method=\"GET\">"
176                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"datadel48h\">"
177                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete older 48h")
178                                 html += "</form>"
179                         else:
180                                 html += "<BR>" + _("File %s does not exists") % "FC2data.csv"
181
182                         html += "</td><td width=\"50%\" align=\"center\" valign=\"top\">Event Logging "
183                         if config.plugins.FanControl.EnableEventLog.value:
184                                 html += "<font color=\"#00FF00\">%s</font>" % _("active")
185                                 html += "<form method=\"GET\">"
186                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsenable\">"
187                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn off")
188                                 html += "</form>"
189                         else:
190                                 html += "<font color=\"#FF0000\">%s</font>" % _("not active")
191                                 html += "<form method=\"GET\">"
192                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsenable\">"
193                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn on")
194                                 html += "</form>"
195                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
196                                 s = os.stat(config.plugins.FanControl.LogPath.value + "FC2events.txt")
197                                 if int(s.st_size/1024) == 0:
198                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size), "")
199                                 else:
200                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size/1024), "k")
201                                 s = os.statvfs(config.plugins.FanControl.LogPath.value)
202                                 html += "<BR>" + _("Disk free : %d MByte") % (int(s.f_bsize * s.f_bavail / 1024 / 1024))
203                                 html += "<form method=\"GET\">"
204                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"events\">"
205                                 html += "<input type=\"submit\" value=\"%s\">" % _("Download")
206                                 html += "</form>"
207                                 html += "<form method=\"GET\">"
208                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsdel\">"
209                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete")
210                                 html += "</form>"
211 #                               html += "<form method=\"GET\">"
212 #                               html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsdel48h\">"
213 #                               html += "<input type=\"submit\" value=\"%s\">" % _("Delete older 48h")
214 #                               html += "</form>"
215
216                         else:
217                                 html += "<BR>" + _("File %s does not exists") % "FC2events.txt"
218                         html += "</td></tr></table>"
219                         html += _("Logging-Path: %s") % config.plugins.FanControl.LogPath.value
220                         html += "</html>"
221
222                 elif command[0] ==  "data":
223                         req.setResponseCode(http.OK)
224 #                       req.setHeader('Content-type', 'application/octet-stream')
225                         req.setHeader('Content-type', 'application/vnd.ms-excel')
226                         req.setHeader('Content-Disposition', 'attachment;filename=FC2data.csv')
227                         req.setHeader('Content-Length', os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv").st_size)
228 #                       req.setHeader('Content-Disposition', 'inline;filename=FC2data.csv')
229                         req.setHeader('charset', 'UTF-8')
230                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
231                         html = f.read()
232                         f.close()
233                 elif command[0] ==  "datadel":
234                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
235                                 os.remove(config.plugins.FanControl.LogPath.value + "FC2data.csv")
236                         CreateDataHead()
237                         html = LogRefresh()
238                 elif command[0] ==  "datadel48h":
239                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv") and os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv").st_size > 10000:
240                                 f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","a")
241                                 s = f.tell()
242                                 f.close()
243                                 f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
244                                 f.seek(s-100)
245                                 line = f.readline()
246                                 line = f.readline()
247                                 DT = line.split(";")
248                                 DT = DT[0].split(" ")
249                                 DD = DT[0].split(".")
250                                 DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
251                                 Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
252                                 f.seek(0)
253                                 line = f.readline()
254                                 fw = open(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp","w")
255                                 fw.write(HeadLine)
256                                 for line in f.readlines():
257                                         DT = line.split(";")
258                                         if DT[0] > Dfind:
259                                                 fw.write(line)
260                                 f.close()
261                                 fw.close()
262                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
263                                         os.remove(config.plugins.FanControl.LogPath.value + "FC2data.csv")
264                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp"):
265                                         os.rename(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp",config.plugins.FanControl.LogPath.value + "FC2data.csv")
266                         html = LogRefresh()
267                 elif command[0] ==  "dataenable":
268                         config.plugins.FanControl.EnableDataLog.value = not config.plugins.FanControl.EnableDataLog.value
269                         CreateDataHead()
270                         config.plugins.FanControl.EnableDataLog.save()
271                         html = LogRefresh()
272
273                 elif command[0] ==  "events":
274                         req.setResponseCode(http.OK)
275                         req.setHeader('Content-type', 'application/octet-stream')
276                         req.setHeader('Content-Disposition', 'attachment;filename=FC2events.txt')
277                         req.setHeader('Content-Length', os.stat(config.plugins.FanControl.LogPath.value + "FC2events.txt").st_size)
278 #                       req.setHeader('Content-Disposition', 'inline;filename=FC2events.txt')
279                         req.setHeader('charset', 'UTF-8')
280                         f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","r")
281                         html = f.read()
282                         f.close()
283                 elif command[0] ==  "eventsdel":
284                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
285                                 os.remove(config.plugins.FanControl.LogPath.value + "FC2events.txt")
286                         html = LogRefresh()
287                 elif command[0] ==  "eventsdel48h":
288                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
289                                 f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","a")
290                                 s = f.tell()
291                                 f.close()
292                                 f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","r")
293                                 f.seek(s-100)
294                                 line = f.readline()
295                                 line = f.readline()
296                                 DT = line.split(";")
297                                 DT = DT[0].split(" ")
298                                 DD = DT[0].split(".")
299                                 DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
300                                 Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
301                                 f.seek(0)
302                                 line = f.readline()
303                                 fw = open(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp","w")
304                                 fw.write(HeadLine)
305                                 for line in f.readlines():
306                                         DT = line.split(";")
307                                         if DT[0] > Dfind:
308                                                 fw.write(line)
309                                 f.close()
310                                 fw.close()
311                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
312                                         os.remove(config.plugins.FanControl.LogPath.value + "FC2events.txt")
313                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp"):
314                                         os.rename(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp",config.plugins.FanControl.LogPath.value + "FC2events.txt")
315                         html = LogRefresh()
316                 elif command[0] ==  "eventsenable":
317                         config.plugins.FanControl.EnableEventLog.value = not config.plugins.FanControl.EnableEventLog.value
318                         config.plugins.FanControl.EnableEventLog.save()
319                         html = LogRefresh()
320
321                 return html
322
323 def LogRefresh():
324         h = "<html>"
325         h += "<head>"
326         h += "<meta http-equiv=\"refresh\" content=\"1; url=/fancontrol/log\">"
327         h += "<a href=\"/fancontrol/log\">Execution completed... jump back...</a>"
328         h += "</html>"
329         h += "</head>"
330         return h
331
332 def CreateDataHead():
333         if not os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv") and config.plugins.FanControl.EnableDataLog.value and Free(config.plugins.FanControl.LogPath.value):
334                 try:
335                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","w")
336                         try:
337                                 f.write(HeadLine)
338                         except:
339                                 f.close()
340                 except IOError:
341                         pass
342
343 ##########################################################
344 class FC2webChart(resource.Resource):
345     
346         title = "FanControl2 Webinterface"
347         isLeaf = True
348     
349         def render(self, req):
350                 command = req.args.get("cmd",None)
351                 html = ""
352                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
353                         req.setHeader('Content-type', 'text/html')
354                         req.setHeader('charset', 'UTF-8')
355
356                         """ rendering server response """
357
358                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","a")
359                         s = f.tell()
360                         f.close()
361                         if s < 150:
362                                 html = "<html><body><html>Not enough Data (wait 3min)!</body></html>"
363                                 return html
364                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
365                         f.seek(s-100)
366                         line = f.readline()
367                         line = f.readline()
368                         DT = line.split(";")
369                         DT = DT[0].split(" ")
370                         DD = DT[0].split(".")
371                         DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
372                         Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
373                         f.seek(0)
374                         line = f.readline()
375                         Anzahl = 0
376                         for line in f.readlines():
377                                 DT = line.split(";")
378                                 if DT[0] > Dfind:
379                                         Anzahl += 1
380 #                       Anzahl -= 1
381                         html = "<html>"
382                         html += "<head>"
383                         html += "<meta http-equiv=\"Content-Language\" content=\"de\">"
384                         html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
385                         html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />"
386                         html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />"
387                         html += "<meta http-equiv=\"expires\" content=\"0\">"
388                         html += "<title>Fan Control 2 - Chart</title>"
389                         html += "</head>"
390                         html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
391                         html += "<table border=\"1\" width=\"900\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"  cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
392                         html += "<p align=\"center\"><img border=\"0\" src=\"/fancontrol/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
393                         html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Chart</b></font></p>\n"
394                         html += "</td><td bgcolor=\"#000000\">\n"
395                         html += "<p align=\"right\">"
396                         html += BoxStatus()
397                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
398                                 html += "<a href=\"/fancontrol\"><img border=\"0\" src=\"/fancontrol/FC2Info.png\" width=\"100\" height=\"40\"></a>\n"
399                         html += "<a href=\"/fancontrol/log\"><img border=\"0\" src=\"/fancontrol/FC2Setup.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
400
401                         html += "<applet code=\"diagram.class\" codebase=\"/fancontrol/\" name=\"DiaTemp\" "
402                         html += "align=\"baseline\" width=\"900\" height=\"250\" mayscript>\n"
403                         html += "<param name=\"title\" value=\"Temp  (48h - %s)\">\n" % DT[0]
404                         html += "<param name=\"bgcolor\" value=\"240; 240; 240\">\n"
405                         html += "<param name=\"ytitle\" value=\"Temp\">\n"
406                         html += "<param name=\"rolling\" value=\"%d\">\n" % Anzahl
407                         html += "<param name=\"show_xscale\" value=\"atText\">\n"
408                         html += "<param name=\"show_ygrid\" value=\"true\">\n"
409                         html += "<param name=\"show_xgrid\" value=\"true\">\n"
410
411                         html += "<param name=\"y0\" value=\"\">\n"
412                         html += "<param name=\"color0\" value=\"240; 0; 0\">\n"
413                         html += "<param name=\"style0\" value=\"LINE\">\n"
414                         html += "<param name=\"ylabel0\" value=\"Temp\">\n"
415
416                         html += "<param name=\"y1\" value=\"\">\n"
417                         html += "<param name=\"color1\" value=\"240; 0; 240\">\n"
418                         html += "<param name=\"style1\" value=\"LINE\">\n"
419                         html += "<param name=\"ylabel1\" value=\"HDD\">\n"
420
421                         html += "<param name=\"y2\" value=\"\">\n"
422                         html += "<param name=\"color2\" value=\"0; 255; 0\">\n"
423                         html += "<param name=\"style2\" value=\"LINE\">\n"
424                         html += "<param name=\"ylabel2\" value=\"BoxOn\">\n"
425
426                         html += "<param name=\"y3\" value=\"\">\n"
427                         html += "<param name=\"color3\" value=\"72; 118; 255\">\n"
428                         html += "<param name=\"style3\" value=\"LINE\">\n"
429                         html += "<param name=\"ylabel3\" value=\"HDDon\">\n"
430
431                         html += "<param name=\"y4\" value=\"\">\n"
432                         html += "<param name=\"color4\" value=\"255; 165; 0\">\n"
433                         html += "<param name=\"style4\" value=\"LINE\">\n"
434                         html += "<param name=\"ylabel4\" value=\"Record\">\n"
435
436                         html += "</applet>\n"
437
438 #                       html += "<div style=\"position: absolute; width: 100px; height: 100px; z-index: 1; left: 910px; top: 146px\" id=\"Ebene1\">\n"
439 #                       html += "<img border=\"0\" src=\"/web-data/fc2/FC2Status.png\" width=\"115\" height=\"168\"></div>\n"
440
441                         html += "<applet code=\"diagram.class\" codebase=\"/fancontrol/\" name=\"DiaRPM\" "
442                         html += "align=\"baseline\" width=\"900\" height=\"250\" mayscript>\n"
443                         html += "<param name=\"title\" value=\"RPM  (48h - %s)\">\n" % DT[0]
444                         html += "<param name=\"bgcolor\" value=\"240; 240; 240\">\n"
445                         html += "<param name=\"ytitle\" value=\"RPM\">\n"
446                         html += "<param name=\"rolling\" value=\"%d\">\n" % Anzahl
447                         html += "<param name=\"show_xscale\" value=\"atText\">\n"
448                         html += "<param name=\"show_ygrid\" value=\"true\">\n"
449                         html += "<param name=\"show_xgrid\" value=\"true\">\n"
450
451                         html += "<param name=\"y0\" value=\"\">\n"
452                         html += "<param name=\"color0\" value=\"240; 0; 0\">\n"
453                         html += "<param name=\"style0\" value=\"LINE\">\n"
454                         html += "<param name=\"ylabel0\" value=\"RPM\">\n"
455
456                         html += "</applet>\n"
457
458                         f.seek(0)
459                         line = f.readline()
460                         html += "<script language=javascript>\n"
461                         html += "dT = document.DiaTemp\n"
462                         html += "dR = document.DiaRPM\n"
463                         t = 0
464                         Xtime = int((Anzahl/20))
465                         if Anzahl < 1000:
466                                 Xtime += 1
467                         for line in f.readlines():
468                                 DT = line.split(";")
469                                 if DT[0] > Dfind:
470                                         if Xtime > 0:
471                                                 tmp = ("\"" + DT[0].split(" ")[1] + "\"") if t % Xtime == 0 else "null"
472                                         else:
473                                                 tmp = "null"
474                                         t += 1
475                                         if len(DT[6])>1:
476                                                 DT[6]="0"
477                                         B = 0
478                                         H = 0
479                                         R = 0
480                                         S = int(DT[6])
481                                         if (S & 1)>0 :
482                                                 B = 3
483                                         if (S & 2)>0 :
484                                                 H = 6
485                                         if (S & 4)>0 :
486                                                 R = 9
487                                         html += "dT.AddPoint(\"%s; %s; %d; %d; %d\", %s, null);\n" % (DT[1].replace(",","."),DT[5],B,H,R,tmp)
488                                         html += "dR.AddPoint(\"%s\", %s, null);\n" % (DT[2],tmp)
489                         f.close()
490                         html += "dT.repaint();\ndR.repaint();\n"
491                         html += "</script>"
492                 else:
493                         html = "<html>no Data!"
494                 html += "</body>"
495                 html += "</html>"
496
497                 return html
498
499 def BoxStatus():
500         h = ""
501         S = int(FC2werte[5])
502         if (S & 1)>0 :
503                 h += "<img border=\"0\" src=\"/fancontrol/FC2on.png\" width=\"20\" height=\"20\" title=\"Box On\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
504         if (S & 2)>0 :
505                 h += "<img border=\"0\" src=\"/fancontrol/FC2hdd.png\" width=\"20\" height=\"20\" title=\"HDD On\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
506         if (S & 4)>0 :
507                 h += "<img border=\"0\" src=\"/fancontrol/FC2record.png\" width=\"20\" height=\"20\" title=\"Recording\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
508         return h