examples adapted for unittest structure

This commit is contained in:
Dirk Alders 2025-08-15 20:26:36 +02:00
parent 14e56ccdbf
commit 95dda53a55
3 changed files with 33 additions and 3 deletions

29
_examples_/Makefile Normal file
View File

@ -0,0 +1,29 @@
# pylibs examples Makefile: Version 1.0 (2025-08-15)
.ONESHELL:
SHELL = /usr/bin/bash
MAKEFLAGS += --no-print-directory
.SILENT:
INTERPRETER = python3
.PHONY: all
EXAMPLES := $(wildcard *.py)
EXAMPLES := $(filter-out config.py, $(EXAMPLES))
LOGFILES := ${EXAMPLES:.py=.log}
LOGFILES_1st := ${EXAMPLES:.py=.log_1st}
all: $(LOGFILES)
-include __make.d__/*.mk
%.log: %.py
$(MAKE) $@_1st 2> /dev/null
echo -e "\e[1m * Running example $<\e[0m"
$(INTERPRETER) $< > $@
localclean:
clean: localclean
echo -e "\e[1m * Example logs...\e[0m"
rm -f $(LOGFILES)
rm -f $(LOGFILES_1st)

View File

@ -1 +0,0 @@
..

View File

@ -1,7 +1,9 @@
import sys # nopep8
sys.path.append("../..") # nopep8
import mqtt
import time
import logging
import sys
root = logging.getLogger('root')
root.setLevel(logging.DEBUG)
@ -18,4 +20,4 @@ def print_msg(client, userdata, message):
c = mqtt.mqtt_client('test', '192.168.0.2', username='', password='')
c.add_callback('ambient/#', print_msg)
while True:
time.sleep(1)
time.sleep(1)