Example #1
0
 def setUpClass(cls):     
     sqlalchemy_enginge = getPostgresEngineString(DBCONFIG_PARAMS_TESTING)
     cls.engine = create_engine(sqlalchemy_enginge, encoding='utf8', echo=True)
     cls.Session = scoped_session(sessionmaker(bind=cls.engine,extension=ZopeTransactionExtension()))
     cls.dbsession = cls.Session()
     cls.testDataDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test-data')
     cls.user = TEST_LOGIN
    def setUpClass(cls):
        print '=============='
        print 'Start GernicJobsTest tests ...'
        print '=============='

        cls.logger = createLogger('GernicJobsTest', logging.DEBUG)
        cls.dbsession = initializeDb(
            getPostgresEngineString(DBCONFIG_PARAMS_TESTING))
    def run(self):
        LOGGER.info('Georeference update runner persistent is started!')
        while True:
            LOGGER.info('Looking for pending georeference processes ...')
            dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS))
            updateDataBasis(dbsession, LOGGER, TEST_MODE)
            dbsession.commit()
            dbsession.close()

            LOGGER.info('Go to sleep ...')
            time.sleep(GEOREFERENCE_DAEMON_SETTINGS['sleep_time'])
    def run(self):
        LOGGER.info('Georeference update runner persistent is started!')
        while True:
            LOGGER.info('Looking for pending georeference processes ...')
            dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS))
            updateDataBasis(dbsession, LOGGER, TEST_MODE)
            dbsession.commit()
            dbsession.close()

            LOGGER.info('Go to sleep ...')
            time.sleep(GEOREFERENCE_DAEMON_SETTINGS['sleep_time'])
    def testLookForUpdateProcess_Infinity(self):
        print "--------------------------------------------------------------------------------------------"
        print "\n"
        print "Test if testLookForUpdateProcess_Infinity runs correctly ..."

        dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS_TESTING), self.logger)
        while True:
            print "New loop run ..."
            updateDataBasis(dbsession, self.logger, True)
            dbsession.commit()
            print "Long sleep ..."
            time.sleep(10)
    def testLookForUpdateProcess(self):
        print "--------------------------------------------------------------------------------------------"
        print "\n"
        print "Test if testLookForUpdateProcess runs correctly ..."

        dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS_TESTING), self.logger)
        response = updateDataBasis(dbsession, self.logger, True)

        # add tests
        # @TODO

        dbsession.rollback()
    def testRunningUpdateJobs(self):
        print "--------------------------------------------------------------------------------------------"
        print "\n"
        print "Test if testRunningUpdateJobs runs correctly ..."

        dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS_TESTING), self.logger)
        response = runningUpdateJobs(dbsession, self.logger, True)

        # add tests
        # @TODO

        dbsession.rollback()
Example #8
0
def loadDB(config, settings, debug=False):
    """ Loads the database connection based on sql alchemy 
    
    @param dict: config
    @param dict: settings
    @param boolean: debug (Default=False) """
    def db(request):
        return request.registry.dbmaker()   
    
    if debug:
        engine = create_engine(getPostgresEngineString(DBCONFIG_PARAMS), encoding='utf8', echo=True)
    else:
        engine = engine_from_config(settings, prefix='sqlalchemy.')
    config.registry.dbmaker = scoped_session(sessionmaker(bind=engine,extension=ZopeTransactionExtension()))
    config.add_request_method(db, reify=True)   
    
    initialize_sql(engine)
    config.scan('models')
Example #9
0
Copyright (c) 2015 Jacob Mendt

Created on 02.10.15

@author: mendt
@description:
    The following scripts pushs all database records to elasticsearch
'''
import logging
from georeference.settings import DBCONFIG_PARAMS
from georeference.models.meta import getPostgresEngineString
from georeference.models.meta import initializeDb
from georeference.models.vkdb.georeferenzierungsprozess import Georeferenzierungsprozess
from georeference.models.vkdb.map import Map
from georeference.persistent.jobs.genericjobs import pushRecordToSearchIndex
from georeference.persistent.jobs.genericjobs import removeRecordFromSearchIndex

if __name__ == '__main__':
    logging.basicConfig()
    logger = logging.getLogger('Push recrords to ES')
    dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS), False)
    maps = Map.all(dbsession)

    for mapObj in maps:
        if mapObj.istaktiv == True:
            print 'Push map record %s to elastic search ...' % mapObj.id
            georefObj = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(mapObj.id, dbsession)
            pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj)
        else:
            print 'Remove map record %s from elastic search ...' % mapObj.id
            removeRecordFromSearchIndex(mapObj)
Example #10
0
Created on 02.10.15

@author: mendt
@description:
    The following scripts pushs all database records to elasticsearch
'''
import logging
from georeference.settings import DBCONFIG_PARAMS
from georeference.models.meta import getPostgresEngineString
from georeference.models.meta import initializeDb
from georeference.models.vkdb.georeferenzierungsprozess import Georeferenzierungsprozess
from georeference.models.vkdb.map import Map
from georeference.persistent.jobs.genericjobs import pushRecordToSearchIndex
from georeference.persistent.jobs.genericjobs import removeRecordFromSearchIndex

if __name__ == '__main__':
    logging.basicConfig()
    logger = logging.getLogger('Push recrords to ES')
    dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS), False)
    maps = Map.all(dbsession)

    for mapObj in maps:
        if mapObj.istaktiv == True:
            print 'Push map record %s to elastic search ...' % mapObj.id
            georefObj = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId(
                mapObj.id, dbsession)
            pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj)
        else:
            print 'Remove map record %s from elastic search ...' % mapObj.id
            removeRecordFromSearchIndex(mapObj)
Example #11
0
 def setUpClass(cls):
     print '=============='
     print 'Start GernicJobsTest tests ...'
     print '=============='
     cls.logger = createLogger('GernicJobsTest', logging.DEBUG)
     cls.dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS_TESTING))