def initialize(configuration,log): # define the global variables used by the server global logger, max_bytes, xmlparser, dbobj, rls global dmt_proc_dict, dmt_seg_def_dict, creator_db global ldbd_com, db2_com, port # initialize the logger logger = log logger.info("Initializing server module %s" % __name__ ) # initialize the database hash table dbobj = ldbd.LIGOMetadataDatabase(configuration['dbname']) max_bytes = configuration['max_client_byte_string'] # initialize the ldbd commands and db2 command restrictions port = configuration['port'] ldbd_com = configuration['ldbd_com'].split(',') db2_com = configuration['db2_com'].split(',') # create the xml parser xmlparser = pyRXP.Parser() # use a local copy of the DTD, if one is available try: GLUE_PREFIX = os.environ["GLUE_PREFIX"] xmlparser.eoCB = dtd_uri_callback logger.info("Using local DTD in " + 'file://localhost' + os.path.join( GLUE_PREFIX, 'etc') ) except KeyError: logger.warning('GLUE_PREFIX not set, unable to use local DTD') # open a connection to the rls server rls_server = configuration['rls'] cert = configuration['certfile'] key = configuration['keyfile'] try: rls = rlsClient.RlsClient(rls_server,cert,key) except: rls = None # initialize dictionaries for the dmt processes and segments definers dmt_proc_dict = {} dmt_seg_def_dict = {} creator_db = None
handler = logging.handlers.RotatingFileHandler(logFilePath, 'a', logMaxBytes, logBackupCount) formatter = logging.Formatter( '%(asctime)s %(name)-12s %(levelname)-8s %(message)s') handler.setFormatter(formatter) rootlogger.addHandler(handler) rootlogger.setLevel(eval("logging.%s" % logLevel)) # create logger to use with correct prefix logger = logging.getLogger('LDBD.Server') logger.info("LDBD server started") # initialize the database hash table dbobj = ldbd.LIGOMetadataDatabase(configuration['dbname']) max_bytes = configuration['max_client_byte_string'] # create the xml parser xmlparser = pyRXP.Parser() def dtd_uri_callback(uri): if uri == 'http://ldas-sw.ligo.caltech.edu/doc/ligolwAPI/html/ligolw_dtd.txt': # if the XML file contants a http pointer to the ligolw DTD at CIT then # return a local copy to avoid any network problems return 'file://localhost' + os.path.join(os.environ["GLUE_PREFIX"], 'etc/ligolw_dtd.txt') else: # otherwise just use the uri in the file return uri