def setUpClass(cls): print '==============' print 'Start GernicJobsTest tests ...' print '==============' cls.logger = createLogger('GernicJobsTest', logging.DEBUG) cls.dbsession = initializeDb( getPostgresEngineString(DBCONFIG_PARAMS_TESTING))
def loadDbSession(database_params): logger.info('Initialize new database connection ...') sqlalchemy_enginge = 'postgresql+psycopg2://%(user)s:%(password)s@%(host)s:5432/%(db)s'%(database_params) try: return initializeDb(sqlalchemy_enginge) except: logger.error('Could not initialize database. Plase check your database settings parameter.') raise ParameterException('Could not initialize database. Plase check your database settings parameter.')
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()
def loadDbSession(database_params): logger.info('Initialize new database connection ...') sqlalchemy_enginge = 'postgresql+psycopg2://%(user)s:%(password)s@%(host)s:5432/%(db)s' % ( database_params) try: return initializeDb(sqlalchemy_enginge) except: logger.error( 'Could not initialize database. Plase check your database settings parameter.' ) raise ParameterException( 'Could not initialize database. Plase check your database settings parameter.' )
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)
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)
def setUpClass(cls): print '==============' print 'Start GernicJobsTest tests ...' print '==============' cls.logger = createLogger('GernicJobsTest', logging.DEBUG) cls.dbsession = initializeDb(getPostgresEngineString(DBCONFIG_PARAMS_TESTING))