Moved code to plugins/enhancer folder

This commit is contained in:
Csaba 2023-12-11 14:55:35 +01:00
parent d78adf7433
commit cc3fb6e622
3 changed files with 38 additions and 27 deletions

View file

@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

View file

@ -8,6 +8,7 @@ from amarillo.app.models.Carpool import Carpool
from amarillo.app.services import stops from amarillo.app.services import stops
from amarillo.app.services import trips from amarillo.app.services import trips
from amarillo.app.services.carpools import CarpoolService from amarillo.app.services.carpools import CarpoolService
from amarillo.app.services import gtfs_generator
from amarillo.app.configuration import configure_services from amarillo.app.configuration import configure_services
@ -49,3 +50,4 @@ def configure_enhancer_services():
logger.info("Restored carpools: %s", container['carpools'].get_all_ids()) logger.info("Restored carpools: %s", container['carpools'].get_all_ids())
logger.info("Starting scheduler") logger.info("Starting scheduler")
gtfs_generator.start_schedule()

View file

@ -1,11 +1,11 @@
import json import json
import time from threading import Thread
import logging import logging
import logging.config import logging.config
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
from enhancer_configuration import configure_enhancer_services from amarillo.plugins.enhancer.configuration import configure_enhancer_services
from amarillo.app.utils.container import container from amarillo.app.utils.container import container
from amarillo.app.models.Carpool import Carpool from amarillo.app.models.Carpool import Carpool
from amarillo.app.utils.utils import agency_carpool_ids_from_filename from amarillo.app.utils.utils import agency_carpool_ids_from_filename
@ -13,13 +13,6 @@ from amarillo.app.utils.utils import agency_carpool_ids_from_filename
logging.config.fileConfig('logging.conf', disable_existing_loggers=False) logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
logger = logging.getLogger("enhancer") logger = logging.getLogger("enhancer")
logger.info("Hello Enhancer")
configure_enhancer_services()
observer = Observer() # Watch Manager
class EventHandler(FileSystemEventHandler): class EventHandler(FileSystemEventHandler):
# TODO FG HB should watch for both carpools and agencies # TODO FG HB should watch for both carpools and agencies
# in data/agency, data/agencyconf, see AgencyConfService # in data/agency, data/agencyconf, see AgencyConfService
@ -47,6 +40,13 @@ class EventHandler(FileSystemEventHandler):
logger.exception("Eventhandler on_deleted encountered exception") logger.exception("Eventhandler on_deleted encountered exception")
def run_enhancer():
logger.info("Hello Enhancer")
configure_enhancer_services()
observer = Observer() # Watch Manager
observer.schedule(EventHandler(), 'data/carpool', recursive=True) observer.schedule(EventHandler(), 'data/carpool', recursive=True)
observer.start() observer.start()
@ -68,3 +68,11 @@ finally:
observer.join() observer.join()
logger.info("Goodbye Enhancer") logger.info("Goodbye Enhancer")
def setup(app):
thread = Thread(target=run_enhancer)
thread.start()
if __name__ == "__main__":
run_enhancer()