🚀 NEUE FEATURES: Push-to-Gitea, Inotify-Watcher, Changelog mit git log
docker-build-and-push / build (push) Successful in 1m54s
docker-build-and-push / build (push) Successful in 1m54s
This commit is contained in:
+19
-20
@@ -1,25 +1,24 @@
|
||||
import time
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class FileChangeHandler(FileSystemEventHandler):
|
||||
def __init__(self, callback=None):
|
||||
self.callback = callback
|
||||
def start_inotify_watcher(path: str, callback=None):
|
||||
"""
|
||||
Startet einen Inotify-Watcher mit dem Befehl 'inotifywait'.
|
||||
Callback wird aufgerufen bei Dateiänderungen.
|
||||
"""
|
||||
# Useinotifywait from inotify-tools package
|
||||
command = [
|
||||
"inotifywait",
|
||||
"-m", "-r", "--format '%w%f %e'",
|
||||
str(path)
|
||||
]
|
||||
|
||||
def on_modified(self, event):
|
||||
if not event.is_directory:
|
||||
if self.callback:
|
||||
self.callback(event.src_path)
|
||||
print(f"[Watcher] Datei geändert: {event.src_path}")
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
)
|
||||
|
||||
|
||||
def start_watcher(path: Path, callback=None):
|
||||
"""Startet den File-Watcher in einem Hintergrundthread."""
|
||||
event_handler = FileChangeHandler(callback=callback)
|
||||
observer = Observer()
|
||||
observer.schedule(event_handler, str(path), recursive=True)
|
||||
observer.start()
|
||||
|
||||
return observer
|
||||
return process
|
||||
Reference in New Issue
Block a user