Moved code to plugins/enhancer folder
This commit is contained in:
parent
bd36c1ec70
commit
c18f347aac
1
amarillo/plugins/__init__.py
Normal file
1
amarillo/plugins/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
||||||
|
|
@ -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()
|
||||||
|
|
@ -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,24 +40,39 @@ class EventHandler(FileSystemEventHandler):
|
||||||
logger.exception("Eventhandler on_deleted encountered exception")
|
logger.exception("Eventhandler on_deleted encountered exception")
|
||||||
|
|
||||||
|
|
||||||
observer.schedule(EventHandler(), 'data/carpool', recursive=True)
|
def run_enhancer():
|
||||||
observer.start()
|
logger.info("Hello Enhancer")
|
||||||
|
|
||||||
import time
|
configure_enhancer_services()
|
||||||
|
|
||||||
try:
|
observer = Observer() # Watch Manager
|
||||||
# TODO FG Is this really needed?
|
|
||||||
cnt = 0
|
|
||||||
ENHANCER_LOG_INTERVAL_IN_S = 600
|
|
||||||
while True:
|
|
||||||
if cnt == ENHANCER_LOG_INTERVAL_IN_S:
|
|
||||||
logger.debug("Currently stored carpool ids: %s", container['carpools'].get_all_ids())
|
|
||||||
cnt = 0
|
|
||||||
|
|
||||||
time.sleep(1)
|
observer.schedule(EventHandler(), 'data/carpool', recursive=True)
|
||||||
cnt += 1
|
observer.start()
|
||||||
finally:
|
|
||||||
observer.stop()
|
|
||||||
observer.join()
|
|
||||||
|
|
||||||
logger.info("Goodbye Enhancer")
|
import time
|
||||||
|
|
||||||
|
try:
|
||||||
|
# TODO FG Is this really needed?
|
||||||
|
cnt = 0
|
||||||
|
ENHANCER_LOG_INTERVAL_IN_S = 600
|
||||||
|
while True:
|
||||||
|
if cnt == ENHANCER_LOG_INTERVAL_IN_S:
|
||||||
|
logger.debug("Currently stored carpool ids: %s", container['carpools'].get_all_ids())
|
||||||
|
cnt = 0
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
cnt += 1
|
||||||
|
finally:
|
||||||
|
observer.stop()
|
||||||
|
observer.join()
|
||||||
|
|
||||||
|
logger.info("Goodbye Enhancer")
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
thread = Thread(target=run_enhancer)
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run_enhancer()
|
||||||
Loading…
Reference in a new issue