SBCHOST = cfg["SBCHOST"] SBCPORT = int(cfg["SBCPORT"]) except KeyError as message: handler.log.critical("no se ha podido encontrar una variable de confifguracion necesaria: %s", message) handler.log.exception(message) exit(1) except Exception as message: handler.log.error("ha ocurrido un error al cargar el archivo de configuracion: " + CONFIGFILE) handler.log.exception(message) exit(1) else: handler.log.info("configuraciones cargadas correctamente") try: AOCMR.run() except Exception as message: handler.log.error("ha ocurrido un error al cargar el modulo AOCMR") handler.log.exception(message) exit(1) # ejecutando el modulo AOCME como hilo try: tAOCME = ThreadxAOCME(HOST, PORT).start() except Exception as message: handler.log.error("ha ocurrido un error al cargar el modulo AOCME") handler.log.exception(message) exit(1) handler.log.info("el agente se ha iniciado correctamente")
cfg = Load(CONFIGFILE) LOGFILE = cfg["LOGFILE"]; setLOGFILE(LOGFILE) LOGLEVEL = cfg["LOGLEVEL"]; setLOGLEVEL(LOGLEVEL) # se importa el Logger una ves instanciados los parametros necesarios para su ejecucion from modulo.Logger import handler handler.log.info('cargando configuraciones') AOCHOST = cfg["AOCHOST"]; setAOCHOST(AOCHOST) AOCPORT = int(cfg["AOCPORT"]); setAOCPORT(AOCPORT) SBCHOST = cfg["SBCHOST"]; setSBCHOST(SBCHOST) SBCPORT = int(cfg["SBCPORT"]); setSBCPORT(SBCPORT) AOCMESLEEPTIME = cfg["AOCMESLEEPTIME"]; AOCME.setAOCMESLEEPTIME(AOCMESLEEPTIME) SBCTIMEOUT = int(cfg["SBCTIMEOUT"]); AOCME.setSBCTIMEOUT(SBCTIMEOUT) AOCMRSLEEPTIME = cfg["AOCMRSLEEPTIME"]; AOCMR.setAOCMRSLEEPTIME(AOCMRSLEEPTIME) except KeyError as message: handler.log.critical('no se ha podido encontrar una variable de configuracion necesaria: %s', message) handler.log.exception(message) exit(1); except Exception as message: handler.log.error('ha ocurrido un error al cargar el archivo de configuracion: ' + CONFIGFILE) handler.log.exception(message) exit(1); else: handler.log.info('configuraciones cargadas correctamente') # main if __name__ == '__main__': handler.log.info('iniciando el agente') try: AOCMR.run()