Example #1
0
	def load_conf(self, conf_files=None, path_env="WEB_CONF_PATH", files_env="WEB_CONF_FILES", default_ext=".cfg"):
		logger = get_logger("wok.server", level="info")
		logger.info("Loading Flask configuration ...")
		conf_path = os.environ.get(path_env, os.getcwd())
		conf_files = _get_conf_files(conf_path, conf_files or [], os.environ.get(files_env), default_ext)
		for cfg_path in conf_files:
			logger.info("+++ {}".format(cfg_path))
			self.config.from_pyfile(cfg_path)
Example #2
0
File: plugin.py Project: bbglab/wok
	def create(self, conf=None, type=None, logger=None):
		type = type or conf.get("type") or self.__default
		if type is None:
			raise PluginError("Missing {} type".format(self.__category))

		if type not in self.__class_map:
			raise PluginError("Unknown {}: {}".format(self.__category, type))

		if logger is not None:
			logger.info("Creating '{}' {} ...".format(type, self.__category))
			logger.debug("{} configuration: {}".format(self.__category.title(), repr(conf)))

		return self.__class_map[type](conf)
Example #3
0
 def load_conf(self,
               conf_files=None,
               path_env="WEB_CONF_PATH",
               files_env="WEB_CONF_FILES",
               default_ext=".cfg"):
     logger = get_logger("wok.server", level="info")
     logger.info("Loading Flask configuration ...")
     conf_path = os.environ.get(path_env, os.getcwd())
     conf_files = _get_conf_files(conf_path, conf_files or [],
                                  os.environ.get(files_env), default_ext)
     for cfg_path in conf_files:
         logger.info("+++ {}".format(cfg_path))
         self.config.from_pyfile(cfg_path)
Example #4
0
    def create(self, conf=None, type=None, logger=None):
        type = type or conf.get("type") or self.__default
        if type is None:
            raise PluginError("Missing {} type".format(self.__category))

        if type not in self.__class_map:
            raise PluginError("Unknown {}: {}".format(self.__category, type))

        if logger is not None:
            logger.info("Creating '{}' {} ...".format(type, self.__category))
            logger.debug("{} configuration: {}".format(self.__category.title(),
                                                       repr(conf)))

        return self.__class_map[type](conf)