Logging Kapitel

This commit is contained in:
2023-04-29 16:32:52 +02:00
parent 9f4428cdbc
commit c8b9518c11
14 changed files with 70 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ CC-BY-SA Olli Graf
|11 | Datum und Zeit|
|12 | Multithreading|
|13 | Netzwerk|
|14 | GPIO|
|15 | Testing|
|14 | Logging|
|15 | GPIO|
|16 | Testing|

2
gpio/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
./__pycache__
./network/__pycache__/*

Binary file not shown.

1
gpio/ledserver.log Normal file
View File

@@ -0,0 +1 @@
2023-04-29 10:49:08,638 [DEBUG] <module>: MAIN: start

32
gpio/ledserver.py Executable file
View File

@@ -0,0 +1,32 @@
#! /usr/bin/python3
from http.server import BaseHTTPRequestHandler,HTTPServer
import logging
logging.basicConfig( format='%(asctime)-15s [%(levelname)s] %(funcName)s: %(message)s', filename='ledserver.log', level=logging.DEBUG)
class http_server:
def __init__(self):
def handler(*args):
myHandler(*args)
server = HTTPServer(('', 8080), handler)
class myHandler(BaseHTTPRequestHandler):
def __init__(self,*args):
self.t1 = t1
BaseHTTPRequestHandler.__init__(self, *args)
def do_GET(self):
logging.debug('GET: empfangen')
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write(self.t1.show()) #Doesnt work
return
class main:
def __init__(self):
self.server = http_server()
if __name__ == '__main__':
logging.debug('MAIN: start')
main()

3
gpio/network/__init__.py Normal file
View File

@@ -0,0 +1,3 @@
from .const import __ADDRESSLOCAL__
#from .const import __ADDRESSREMOTE__

Binary file not shown.

Binary file not shown.

10
gpio/network/code.py Normal file
View File

@@ -0,0 +1,10 @@
def receive(conn):
msg = conn.recv(64).decode('utf-8')
return msg
def send(client, msg):
message = msg.encode('utf-8')
client.send(message)

19
gpio/network/const.py Normal file
View File

@@ -0,0 +1,19 @@
#network/const.py
import socket
# TCP Port
__PORT__ = 6554
#Server-IP
# für den Server (immer localhost)
__SERVERLOCAL__ = socket.gethostbyname(socket.gethostname())
#für Server auf einem Remote-Pi
#__SERVERREMOTE__ = socket.gethostbyname('gabbo')
# Server-Adresse (IP,Port)
#lokal
__ADDRESSLOCAL__ = (__SERVERLOCAL__,__PORT__)
#remote
#__ADDRESSREMOTE__ = (__SERVERREMOTE__,__PORT__)