major styling pass, artist list, and import processing improvements
This commit is contained in:
+28
-10
@@ -1,20 +1,38 @@
|
||||
# image_import_loop.py
|
||||
import time
|
||||
import os
|
||||
from app import create_app
|
||||
from app.utils.image_importer import import_images_task
|
||||
|
||||
TRIGGER_FLAG = "/import/trigger.flag"
|
||||
SOURCE_DIR = "/import"
|
||||
DEST_DIR = "/images"
|
||||
CHECK_INTERVAL = 10 # seconds
|
||||
|
||||
app = create_app()
|
||||
|
||||
def looped_import(source_dir='/import', dest_dir='/images', delay_seconds=7200):
|
||||
def monitor_and_import():
|
||||
with app.app_context():
|
||||
print("[Image Importer] Starting import task...")
|
||||
try:
|
||||
result = import_images_task(source_dir, dest_dir)
|
||||
print(f"[Image Importer] {result}")
|
||||
except Exception as e:
|
||||
print(f"[Image Importer] Error: {e}")
|
||||
print(f"[Image Importer] Sleeping for {delay_seconds / 3600:.1f} hours...\n")
|
||||
time.sleep(delay_seconds)
|
||||
print("[Image Importer] Monitoring for trigger flag...")
|
||||
|
||||
while True:
|
||||
if os.path.exists(TRIGGER_FLAG):
|
||||
print("[Image Importer] Trigger flag found. Starting import...")
|
||||
try:
|
||||
result = import_images_task(SOURCE_DIR, DEST_DIR)
|
||||
print(f"[Image Importer] {result}")
|
||||
except Exception as e:
|
||||
print(f"[Image Importer] Error during import: {e}")
|
||||
finally:
|
||||
try:
|
||||
os.remove(TRIGGER_FLAG)
|
||||
print("[Image Importer] Trigger flag cleared.")
|
||||
except Exception as e:
|
||||
print(f"[Image Importer] Failed to remove trigger flag: {e}")
|
||||
else:
|
||||
print("[Image Importer] No trigger flag. Sleeping...")
|
||||
|
||||
time.sleep(CHECK_INTERVAL)
|
||||
|
||||
if __name__ == '__main__':
|
||||
looped_import()
|
||||
monitor_and_import()
|
||||
|
||||
Reference in New Issue
Block a user