def get_config_and_logger(parent, source_config_path, destination_config_path): ConfigUpdater.copy_config(source_config_path, destination_config_path) # Creating an object of the configuration file (standard values) config = configparser.RawConfigParser() config.optionxform = str config.read(destination_config_path) ConfigUpdater.set_constant_values(config) log_level = config.get("IO", "log.level", fallback="DEBUG") logger = MessageLogger.set_and_get_logger_parent(id="", level=log_level, parent=parent) for section in config.sections(): logger.info("[" + section + "]") for key, value in config.items(section): logger.info(key + " = " + value) return config, logger
def setup(): signal.signal(signal.SIGINT, signal_handler) config_path = "/usr/src/app/optimization/resources/ConfigFile.properties" config_path_default = "/usr/src/app/config/ConfigFile.properties" ConfigUpdater.copy_config(config_path_default, config_path) # Creating an object of the configuration file (standard values) config = configparser.RawConfigParser() config.read(config_path) log_level = config.get("IO", "log.level", fallback="DEBUG") logger = MessageLogger.set_and_get_logger_parent(id="", level=log_level) redisDB = clear_redis(logger) copy_models() copy_env_varibles() #logger.debug("env = "+str(os.environ)) zmqHost = config.get("IO", "zmq.host") pubPort = config.get("IO", "zmq.pub.port") subPort = config.get("IO", "zmq.sub.port") zmqForwarder = ForwarderDevice(zmqHost, pubPort, subPort) zmqForwarder.start() return logger, redisDB
""" Created on Okt 19 11:53 2018 @author: nishit """ import configparser from config.configUpdater import ConfigUpdater from connector.Connector import Connector from utils_intern.messageLogger import MessageLogger connector_status = {} if __name__ == '__main__': config = None config_path = "/usr/src/app/connector/resources/connectorConfig.properties" config_path_default = "/usr/src/app/config/connectorConfig.properties" ConfigUpdater.copy_config(config_path_default, config_path, True) config = configparser.ConfigParser() config.optionxform = str config.read(config_path) log_level = config.get("IO", "log.level", fallback="DEBUG") logger = MessageLogger.set_and_get_logger_parent(id="", level=log_level) connector = Connector(config)