Skip to content

Commit 22becd2

Browse files
author
Rebecka Gulliksson
committed
Pass base url to plugin on load.
1 parent abef28d commit 22becd2

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/satosa/plugin_loader.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def load_backends(config, callback, internal_attributes):
3737
:return: A list of backend modules
3838
"""
3939
return _load_endpoint_modules(
40-
_load_plugins(config.PLUGIN_PATH, config.BACKEND_MODULES, backend_filter,
41-
BackendModulePlugin.__name__,
42-
config.BASE),
43-
callback, internal_attributes)
40+
_load_plugins(config.PLUGIN_PATH, config.BACKEND_MODULES, backend_filter,
41+
BackendModulePlugin.__name__,
42+
config.BASE),
43+
callback, internal_attributes)
4444

4545

4646
def load_frontends(config, callback, internal_attributes):
@@ -59,10 +59,10 @@ def load_frontends(config, callback, internal_attributes):
5959
:return: A dict of frontend modules
6060
"""
6161
return _load_endpoint_modules(
62-
_load_plugins(config.PLUGIN_PATH, config.FRONTEND_MODULES, frontend_filter,
63-
FrontendModulePlugin.__name__,
64-
config.BASE),
65-
callback, internal_attributes)
62+
_load_plugins(config.PLUGIN_PATH, config.FRONTEND_MODULES, frontend_filter,
63+
FrontendModulePlugin.__name__,
64+
config.BASE),
65+
callback, internal_attributes)
6666

6767

6868
def _member_filter(member):
@@ -213,7 +213,7 @@ def _load_json(config):
213213
if file_config is not None and os.path.isfile(file_config):
214214
LOGGER.exception("The configuration file %s is corrupt." % file_config)
215215
raise SATOSAConfigurationError(
216-
"The configuration file %s is corrupt." % file_config)
216+
"The configuration file %s is corrupt." % file_config)
217217
return None
218218
except ValueError as error:
219219
if file_config is not None and os.path.isfile(file_config):
@@ -250,7 +250,7 @@ def _load_yaml(config):
250250
if file_config is not None and os.path.isfile(file_config):
251251
LOGGER.exception("The configuration file %s is corrupt." % file_config)
252252
raise SATOSAConfigurationError(
253-
"The configuration file %s is corrupt." % file_config)
253+
"The configuration file %s is corrupt." % file_config)
254254
return None
255255
except Exception as error:
256256
if file_config is not None and os.path.isfile(file_config):
@@ -280,7 +280,8 @@ def _readfile(config):
280280
return None
281281

282282

283-
def _load_plugins(plugin_path, plugins, plugin_filter, filter_class, base_url, internal_attributes=None, *args):
283+
def _load_plugins(plugin_path, plugins, plugin_filter, filter_class, base_url,
284+
internal_attributes=None, *args):
284285
"""
285286
Loads endpoint plugins
286287
@@ -305,7 +306,7 @@ def _load_plugins(plugin_path, plugins, plugin_filter, filter_class, base_url, i
305306
try:
306307
module = plugin_source.load_plugin(module_file_name)
307308
for name, obj in inspect.getmembers(module, plugin_filter):
308-
loaded_plugins.append(obj(*args))
309+
loaded_plugins.append(obj(base_url, *args))
309310
loaded_plugin_names.append(module_file_name)
310311
except ImportError as error:
311312
LOGGER.debug("Not a py file or import error '%s': %s", module_file_name, error)
@@ -318,11 +319,11 @@ def _load_plugins(plugin_path, plugins, plugin_filter, filter_class, base_url, i
318319
for parser in dict_parsers:
319320
_config = parser("%s/%s" % (path, module_file_name))
320321
if _config and "plugin" in _config:
321-
if _config["plugin"] == filter_class:
322-
done = True
323-
break
324-
else:
325-
_config = None
322+
if _config["plugin"] == filter_class:
323+
done = True
324+
break
325+
else:
326+
_config = None
326327
if done:
327328
break
328329
if _config is not None:
@@ -371,7 +372,7 @@ def _load_plugins(plugin_path, plugins, plugin_filter, filter_class, base_url, i
371372
except Exception as error:
372373
LOGGER.exception("The configuration file %s is corrupt." % module_file_name)
373374
raise SATOSAConfigurationError(
374-
"The configuration file %s is corrupt." % module_file_name) from error
375+
"The configuration file %s is corrupt." % module_file_name) from error
375376
LOGGER.debug("Loaded plugins: {}".format(loaded_plugin_names))
376377
return loaded_plugins
377378

@@ -397,9 +398,10 @@ def load_micro_services(plugin_path, plugins, internal_attributes):
397398
internal_attributes=internal_attributes)
398399

399400
LOGGER.info(
400-
"Loaded request micro services: %s" % [k.__class__.__name__ for k in request_services])
401+
"Loaded request micro services: %s" % [k.__class__.__name__ for k in request_services])
401402
LOGGER.info(
402-
"Loaded response micro services: %s" % [k.__class__.__name__ for k in response_services])
403+
"Loaded response micro services: %s" % [k.__class__.__name__ for k in
404+
response_services])
403405

404406
return (
405407
build_micro_service_queue(request_services), build_micro_service_queue(response_services))

0 commit comments

Comments
 (0)