Improve plugin error handling
This commit is contained in:
parent
9cf07355ce
commit
c0e08eae79
@ -101,13 +101,16 @@ class Onionr:
|
||||
os.mkdir('data/blocks/')
|
||||
|
||||
# Copy default plugins into plugins folder
|
||||
|
||||
if not os.path.exists('data/plugins/'):
|
||||
if os.path.exists('default-plugins/'):
|
||||
names = [f for f in os.listdir("default-plugins/") if not os.path.isfile(f)]
|
||||
shutil.copytree('default-plugins/', 'data/plugins/')
|
||||
|
||||
# Enable plugins
|
||||
for name in names:
|
||||
plugins.enable(name, self)
|
||||
if not name in plugins.get_enabled_plugins():
|
||||
plugins.enable(name, self)
|
||||
|
||||
if not os.path.exists(self.onionrCore.peerDB):
|
||||
self.onionrCore.createPeerDB()
|
||||
|
@ -31,6 +31,9 @@ def event(event_name, data = {}, onionr = None):
|
||||
for plugin in plugins.get_enabled_plugins():
|
||||
try:
|
||||
call(plugins.get_plugin(plugin), event_name, data, get_pluginapi(onionr, data))
|
||||
except ModuleNotFoundError as e:
|
||||
logger.warn('Disabling nonexistant plugin \"' + plugin + '\"...')
|
||||
plugins.disable(plugin, onionr, stop_event = False)
|
||||
except Exception as e:
|
||||
logger.warn('Event \"' + event_name + '\" failed for plugin \"' + plugin + '\".')
|
||||
logger.debug(str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user