#!/usr/bin/env python ####wird nicht mehr verwendet import socket import cgi_tools import cgitb cgitb.enable() cgi_tools.print_header('Start') cgi_tools.print_headline('Start') print("<main>") print("<p>fehlt noch</p>") command = "/usr/bin/sudo /sbin/shutdown -r now" import subprocess process = subprocess.Popen(command.split(), stdout=subprocess.PIPE) output = process.communicate()[0] print("<p>" + str(output) + "</p>") #cgi_tools.print_image_link(img_name) print("</main>") cgi_tools.print_footer('/index.html', 'Hauptseite') cgi_tools.print_close()
temp_zaun)) wi_staerke = float(cgi_tools.socket_send('Sensoren;lesen;Wi_Stae_St')) print('<tr><td>Windstärke: </td><td> {:2.1f} km/h</td></tr>'.format( wi_staerke)) wi_boe = float(cgi_tools.socket_send('Sensoren;lesen;Wi_Boe_St')) print('<tr><td>Windboen: </td><td> {:2.1f} km/h</td></tr>'.format(wi_boe)) regen = float(cgi_tools.socket_send('Sensoren;lesen;Reg_St')) print('<tr><td>Regen: </td><td> {:2.2f} mm/min</td></tr>'.format(regen)) bar = float(cgi_tools.socket_send('Sensoren;lesen;Bar_GH_aus_Druck')) print('<tr><td>Luftdruck: </td><td> {:4.0f} hPa</td></tr>'.format( bar)) lum = float(cgi_tools.socket_send('Sensoren;lesen;Lum_GH_Lum')) print('<tr><td>Helligkeit: </td><td> {:2.0f} </td></tr>'.format(lum)) hyg = float(cgi_tools.socket_send('Sensoren;lesen;Bar_GH_aus_Hyg')) print('<tr><td>rel. Luftfeuchte: </td><td> {:2.0f} % </td></tr>'.format( hyg)) hygbod = float(cgi_tools.socket_send('Sensoren;lesen;HygBod')) print('<tr><td>Bodenfeuchte: </td><td> {:02.3f} V </td></tr>'.format( hygbod)) print("</table>") print('Stand: {:s} <p>'.format(zeit)) cgi_tools.print_header('aktuelle Wetterdaten') cgi_tools.print_headline('aktuelle Wetterdaten') print("<main>") get_data() print("</main>") cgi_tools.print_footer('/index.html', 'Hauptseite') cgi_tools.print_close()
#!/usr/bin/env python import socket import cgi_tools import cgitb cgitb.enable() logpath = "/home/pi/usb/Garten/log/" def get_data(): with open(logpath + "my.log", "r", encoding='utf8') as fobj: #with open("x:\Garten/gh_data/my.log", "r", encoding='utf8') as fobj: lines = fobj.readlines() maxline = len(lines) for i in range(1, maxline + 1): line = lines[maxline - i] #Sonderzeichen html-konform wandeln line = line.encode('ascii', 'xmlcharrefreplace') #bytes in string wandeln line = line.decode('ascii') print('<p class="log">', line.rstrip(), '</p>') cgi_tools.print_header('Logfile') cgi_tools.print_headline('Logfile') print("<main><logging>") get_data() print("</logging></main>") cgi_tools.print_footer('/index.html', 'Hauptseite') cgi_tools.print_close()
#!/usr/bin/env python ####wird nicht mehr verwendet import socket import cgi_tools import cgitb cgitb.enable() cgi_tools.print_header('Stop') cgi_tools.print_headline('Stop') print("<main>") cgi_tools.socket_send('stop') #cgi_tools.print_image_link(img_name) print("</main>") cgi_tools.print_footer('/index.html', 'Hauptseite') cgi_tools.print_close()