Browse Source

Logging Kapitel

develop
Olli Graf 2 years ago
parent
commit
c8b9518c11
  1. 5
      Readme.md
  2. 2
      gpio/.gitignore
  3. BIN
      gpio/__pycache__/led.cpython-39.pyc
  4. 0
      gpio/led.py
  5. 1
      gpio/ledserver.log
  6. 32
      gpio/ledserver.py
  7. 3
      gpio/network/__init__.py
  8. BIN
      gpio/network/__pycache__/__init__.cpython-39.pyc
  9. BIN
      gpio/network/__pycache__/const.cpython-39.pyc
  10. 10
      gpio/network/code.py
  11. 19
      gpio/network/const.py
  12. 0
      teil14/conf.py
  13. 0
      teil14/test.log
  14. 0
      teil14/testlogging.py

5
Readme.md

@ -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

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

BIN
gpio/__pycache__/led.cpython-39.pyc

Binary file not shown.

0
teil14/led.py → gpio/led.py

1
gpio/ledserver.log

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

32
gpio/ledserver.py

@ -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

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

BIN
gpio/network/__pycache__/__init__.cpython-39.pyc

Binary file not shown.

BIN
gpio/network/__pycache__/const.cpython-39.pyc

Binary file not shown.

10
gpio/network/code.py

@ -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

@ -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__)

0
logging/conf.py → teil14/conf.py

0
logging/test.log → teil14/test.log

0
logging/testlogging.py → teil14/testlogging.py

Loading…
Cancel
Save