forked from platypush/platypush
FIX: get_plugin methods should never swallow errors in case of failed initialization
This commit is contained in:
parent
e4eb12fa6d
commit
1914322fda
3 changed files with 13 additions and 8 deletions
|
@ -4,6 +4,7 @@ import logging
|
||||||
|
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
|
from ..bus import Bus
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from ..utils import get_enabled_plugins
|
from ..utils import get_enabled_plugins
|
||||||
|
|
||||||
|
@ -129,8 +130,9 @@ def get_plugin(plugin_name, reload=False):
|
||||||
return plugins[plugin_name]
|
return plugins[plugin_name]
|
||||||
|
|
||||||
|
|
||||||
def get_bus():
|
def get_bus() -> Bus:
|
||||||
global main_bus
|
global main_bus
|
||||||
|
assert main_bus, 'The bus is not registered'
|
||||||
return main_bus
|
return main_bus
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,8 @@ class InspectPlugin(Plugin):
|
||||||
try:
|
try:
|
||||||
module = importlib.import_module(modname)
|
module = importlib.import_module(modname)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.debug(f'Could not import module {modname}: {str(e)}')
|
self.logger.warning(f'Could not import module {modname}')
|
||||||
|
self.logger.exception(e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for _, obj in inspect.getmembers(module):
|
for _, obj in inspect.getmembers(module):
|
||||||
|
|
|
@ -248,11 +248,12 @@ def set_thread_name(name):
|
||||||
|
|
||||||
|
|
||||||
def find_bins_in_path(bin_name):
|
def find_bins_in_path(bin_name):
|
||||||
return [os.path.join(p, bin_name)
|
return [
|
||||||
for p in os.environ.get('PATH', '').split(':')
|
os.path.join(p, bin_name)
|
||||||
if os.path.isfile(os.path.join(p, bin_name))
|
for p in os.environ.get('PATH', '').split(':')
|
||||||
and (os.name == 'nt' or
|
if os.path.isfile(os.path.join(p, bin_name)) and (
|
||||||
os.access(os.path.join(p, bin_name), os.X_OK))]
|
os.name == 'nt' or os.access(os.path.join(p, bin_name), os.X_OK)
|
||||||
|
)]
|
||||||
|
|
||||||
|
|
||||||
def find_files_by_ext(directory, *exts):
|
def find_files_by_ext(directory, *exts):
|
||||||
|
@ -444,7 +445,8 @@ def get_enabled_plugins() -> dict:
|
||||||
if plugin:
|
if plugin:
|
||||||
plugins[name] = plugin
|
plugins[name] = plugin
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f'Could not get plugin {name}: {e}')
|
logger.warning(f'Could not initialize plugin {name}')
|
||||||
|
logger.exception(e)
|
||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue