In progress: Jeeves communication is now based on SQLAlchemy
This commit is contained in:
parent
0fdc029153
commit
28726fee01
21 changed files with 637 additions and 78 deletions
|
|
@ -1,19 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pprint
|
||||
import yaml
|
||||
import signal
|
||||
import sys
|
||||
|
||||
import logging
|
||||
import logging.config
|
||||
# import logging
|
||||
# import logging.config
|
||||
|
||||
from alembic.config import Config
|
||||
from alembic import command
|
||||
|
||||
from pyjeeves.connector import DBConnector
|
||||
from pyjeeves import config
|
||||
from process import Process
|
||||
from jvsquery import JvsQuery
|
||||
from db import MySQLSession
|
||||
from utils import TaskThread
|
||||
|
||||
|
||||
|
|
@ -25,8 +25,9 @@ class SyncTread(TaskThread):
|
|||
def __init__(self, config):
|
||||
super(SyncTread, self).__init__()
|
||||
|
||||
jvs_query = JvsQuery(config['jeeves_db'])
|
||||
db_session = MySQLSession(config['mysql'])
|
||||
# Use RawSession instead...
|
||||
jvs_query = JvsQuery()
|
||||
None, db_session = DBConnector.create_scoped_session(['meta'])
|
||||
self.process = Process(jvs_query, db_session)
|
||||
|
||||
self.logger = logging.getLogger("PyJeeves.SyncTread")
|
||||
|
|
@ -38,16 +39,15 @@ class SyncTread(TaskThread):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open("config.yml", 'r') as ymlfile:
|
||||
cfg = yaml.load(ymlfile)
|
||||
|
||||
logging.config.dictConfig(cfg['logging'])
|
||||
from pyjeeves import logging
|
||||
# logging.config.dictConfig(config['logging'])
|
||||
logger = logging.getLogger("PyJeeves")
|
||||
|
||||
logger.info("Running migrations")
|
||||
alembic_cfg = Config()
|
||||
for k in cfg['alembic']:
|
||||
alembic_cfg.set_main_option(k, cfg['alembic'][k])
|
||||
for k in config['alembic']:
|
||||
alembic_cfg.set_main_option(k, config['alembic'][k])
|
||||
command.upgrade(alembic_cfg, "head")
|
||||
|
||||
logger.info("Application started")
|
||||
|
|
@ -59,9 +59,9 @@ if __name__ == '__main__':
|
|||
signal.signal(signal.SIGINT, sigterm_handler)
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
|
||||
sync_thread = SyncTread(cfg)
|
||||
sync_thread = SyncTread()
|
||||
try:
|
||||
sync_thread.setInterval(cfg['sync_interval'])
|
||||
sync_thread.setInterval(config['sync_interval'])
|
||||
sync_thread.start()
|
||||
sync_thread.join()
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue