Merge "Suppress annoying "Could not load" stevedore warnings"
This commit is contained in:
commit
b4a7e05bb7
@ -327,6 +327,24 @@ def replace_file(file_name, data, file_mode=0o644):
|
|||||||
file_utils.replace_file(file_name, data, file_mode=file_mode)
|
file_utils.replace_file(file_name, data, file_mode=file_mode)
|
||||||
|
|
||||||
|
|
||||||
|
class _SilentDriverManager(driver.DriverManager):
|
||||||
|
"""The lamest of hacks to allow us to pass a kwarg to DriverManager parent.
|
||||||
|
|
||||||
|
DriverManager doesn't accept the warn_on_missing_entrypoint param
|
||||||
|
to pass to its parent on __init__ so we mirror the __init__ here and bypass
|
||||||
|
the one in DriverManager in order to silence the warnings.
|
||||||
|
TODO(kevinbenton): remove once Ia6f5f749fc2f73ca6091fa6d58506fddb058902a
|
||||||
|
is released or we stop supporting loading by class path.
|
||||||
|
"""
|
||||||
|
def __init__(self, namespace, name):
|
||||||
|
p = super(driver.DriverManager, self) # pylint: disable=bad-super-call
|
||||||
|
p.__init__(
|
||||||
|
namespace=namespace, names=[name],
|
||||||
|
on_load_failure_callback=self._default_on_load_failure,
|
||||||
|
warn_on_missing_entrypoint=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def load_class_by_alias_or_classname(namespace, name):
|
def load_class_by_alias_or_classname(namespace, name):
|
||||||
"""Load class using stevedore alias or the class name
|
"""Load class using stevedore alias or the class name
|
||||||
:param namespace: namespace where the alias is defined
|
:param namespace: namespace where the alias is defined
|
||||||
@ -340,7 +358,7 @@ def load_class_by_alias_or_classname(namespace, name):
|
|||||||
raise ImportError(_("Class not found."))
|
raise ImportError(_("Class not found."))
|
||||||
try:
|
try:
|
||||||
# Try to resolve class by alias
|
# Try to resolve class by alias
|
||||||
mgr = driver.DriverManager(namespace, name)
|
mgr = _SilentDriverManager(namespace, name)
|
||||||
class_to_load = mgr.driver
|
class_to_load = mgr.driver
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
e1_info = sys.exc_info()
|
e1_info = sys.exc_info()
|
||||||
|
Loading…
Reference in New Issue
Block a user