diff --git a/_examples_/Makefile b/_examples_/Makefile new file mode 100644 index 0000000..f1b262b --- /dev/null +++ b/_examples_/Makefile @@ -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) diff --git a/_examples_/mqtt b/_examples_/mqtt deleted file mode 120000 index a96aa0e..0000000 --- a/_examples_/mqtt +++ /dev/null @@ -1 +0,0 @@ -.. \ No newline at end of file diff --git a/_examples_/test.py b/_examples_/test.py index f912db1..3135257 100644 --- a/_examples_/test.py +++ b/_examples_/test.py @@ -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) \ No newline at end of file + time.sleep(1)