def get_app_kwds(cls, config_section, app_name=None): kwds = { 'config_file': None, 'config_section': config_section, } uwsgi_opt = uwsgi.opt config_file = None # check for --set galaxy_config_file=<path>, this overrides whatever config file uWSGI was loaded with (which # may not actually include a Galaxy config) if uwsgi_opt.get("galaxy_config_file"): config_file = uwsgi_opt.get("galaxy_config_file") # check for --yaml or --json uWSGI config options next if config_file is None: config_file = (UWSGIApplicationStack._get_config_file(uwsgi_opt.get("yaml"), yaml.safe_load, config_section) or UWSGIApplicationStack._get_config_file(uwsgi_opt.get("json"), json.load, config_section)) # --ini and --ini-paste don't behave the same way, but this method will only be called by mules if the main # application was loaded with --ini-paste, so we can make some assumptions, most notably, uWSGI does not have # any way to set the app name when loading with paste.deploy:loadapp(), so hardcoding the alternate section # name to `app:main` is fine. has_ini_config = config_file is None and uwsgi_opt.get("ini") or uwsgi_opt.get("ini-paste") has_ini_config = has_ini_config or (config_file and has_ext(config_file, "ini", aliases=True, ignore="sample")) if has_ini_config: config_file = config_file or uwsgi_opt.get("ini") or uwsgi_opt.get("ini-paste") parser = nice_config_parser(config_file) if not parser.has_section(config_section) and parser.has_section('app:main'): kwds['config_section'] = 'app:main' kwds['config_file'] = unicodify(config_file) return kwds
def get_app_kwds(cls, config_section, app_name=None): kwds = { 'config_file': None, 'config_section': config_section, } uwsgi_opt = uwsgi.opt config_file = None # check for --set galaxy_config_file=<path>, this overrides whatever config file uWSGI was loaded with (which # may not actually include a Galaxy config) if uwsgi_opt.get("galaxy_config_file"): config_file = uwsgi_opt.get("galaxy_config_file") # check for --yaml or --json uWSGI config options next if config_file is None: config_file = (UWSGIApplicationStack._get_config_file(uwsgi_opt.get("yaml"), yaml.safe_load, config_section) or UWSGIApplicationStack._get_config_file(uwsgi_opt.get("json"), json.load, config_section)) # --ini and --ini-paste don't behave the same way, but this method will only be called by mules if the main # application was loaded with --ini-paste, so we can make some assumptions, most notably, uWSGI does not have # any way to set the app name when loading with paste.deploy:loadapp(), so hardcoding the alternate section # name to `app:main` is fine. has_ini_config = config_file is None and uwsgi_opt.get("ini") or uwsgi_opt.get("ini-paste") has_ini_config = has_ini_config or (config_file and has_ext(config_file, "ini", aliases=True, ignore="sample")) if has_ini_config: config_file = config_file or uwsgi_opt.get("ini") or uwsgi_opt.get("ini-paste") parser = nice_config_parser(config_file) if not parser.has_section(config_section) and parser.has_section('app:main'): kwds['config_section'] = 'app:main' kwds['config_file'] = config_file return kwds
def read_properties_from_file(config_file, config_section=None): properties = {} if has_ext(config_file, 'yaml', aliases=True, ignore='sample'): if config_section is None: config_section = "galaxy" properties.update(__default_properties(config_file)) raw_properties = _read_from_yaml_file(config_file) if raw_properties: properties.update(raw_properties.get(config_section) or {}) elif has_ext(config_file, 'ini', aliases=True, ignore='sample'): if config_section is None: config_section = "app:main" parser = nice_config_parser(config_file) # default properties loaded w/parser if parser.has_section(config_section): properties.update(dict(parser.items(config_section))) else: properties.update(parser.defaults()) else: raise InvalidFileFormatError() return properties
def load_app_properties( kwds={}, ini_file=None, ini_section=None, config_file=None, config_section=None, config_prefix="GALAXY_CONFIG_" ): properties = kwds.copy() if kwds else {} if config_file is None: config_file = ini_file config_section = ini_section if config_file: if not has_ext(config_file, 'yaml', aliases=True, ignore='sample'): if config_section is None: config_section = "app:main" parser = nice_config_parser(config_file) if parser.has_section(config_section): properties.update(dict(parser.items(config_section))) else: properties.update(parser.defaults()) else: if config_section is None: config_section = "galaxy" with open(config_file, "r") as f: raw_properties = yaml.safe_load(f) properties = __default_properties(config_file) properties.update(raw_properties.get(config_section) or {}) override_prefix = "%sOVERRIDE_" % config_prefix for key in os.environ: if key.startswith(override_prefix): config_key = key[len(override_prefix):].lower() properties[config_key] = os.environ[key] elif key.startswith(config_prefix): config_key = key[len(config_prefix):].lower() if config_key not in properties: properties[config_key] = os.environ[key] return properties
def load_app_properties(kwds={}, ini_file=None, ini_section=None, config_file=None, config_section=None, config_prefix="GALAXY_CONFIG_"): properties = kwds.copy() if kwds else {} if config_file is None: config_file = ini_file config_section = ini_section if config_file: if not has_ext(config_file, 'yaml', aliases=True, ignore='sample'): if config_section is None: config_section = "app:main" parser = nice_config_parser(config_file) if parser.has_section(config_section): properties.update(dict(parser.items(config_section))) else: properties.update(parser.defaults()) else: if config_section is None: config_section = "galaxy" with open(config_file, "r") as f: raw_properties = yaml.safe_load(f) properties = __default_properties(config_file) properties.update(raw_properties.get(config_section) or {}) override_prefix = "%sOVERRIDE_" % config_prefix for key in os.environ: if key.startswith(override_prefix): config_key = key[len(override_prefix):].lower() properties[config_key] = os.environ[key] elif key.startswith(config_prefix): config_key = key[len(config_prefix):].lower() if config_key not in properties: properties[config_key] = os.environ[key] return properties