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