ahenk is running if there is no plugin

This commit is contained in:
Volkan Şahin 2016-05-17 12:32:48 +03:00
parent 7d829bef7d
commit 36244b3723

View file

@ -38,18 +38,22 @@ class PluginManager(object):
self.logger.info('[PluginManager] Loading plugins...') self.logger.info('[PluginManager] Loading plugins...')
self.plugins = [] self.plugins = []
self.logger.debug('[PluginManager] Lookup for possible plugins...') self.logger.debug('[PluginManager] Lookup for possible plugins...')
possibleplugins = os.listdir(self.configManager.get("PLUGIN", "pluginFolderPath"))
self.logger.debug('[PluginManager] Possible plugins.. ' + str(possibleplugins)) try:
for pname in possibleplugins: possible_plugins = os.listdir(self.configManager.get("PLUGIN", "pluginFolderPath"))
location = os.path.join(self.configManager.get("PLUGIN", "pluginFolderPath"), pname) self.logger.debug('[PluginManager] Possible plugins: {} '.format(str(possible_plugins)))
if not os.path.isdir(location) or not self.configManager.get("PLUGIN", "mainModuleName") + ".py" in os.listdir(location): for plugin_name in possible_plugins:
self.logger.debug('It is not a plugin location ! There is no main module - ' + str(location)) location = os.path.join(self.configManager.get("PLUGIN", "pluginFolderPath"), plugin_name)
continue if not os.path.isdir(location) or not self.configManager.get("PLUGIN", "mainModuleName") + ".py" in os.listdir(location):
try: self.logger.debug('It is not a plugin location ! There is no main module - {}'.format(str(location)))
self.loadSinglePlugin(pname) continue
except Exception as e: try:
self.logger.error('[PluginManager] Exception occured when loading plugin ! Plugin name : ' + str(pname) + ' Exception : ' + str(e)) self.loadSinglePlugin(plugin_name)
self.logger.info('[PluginManager] Loaded plugins successfully.') except Exception as e:
self.logger.error('[PluginManager] Exception occurred when loading plugin ! Plugin name : {} .Error Message: {}'.format(str(plugin_name), str(e)))
self.logger.info('[PluginManager] Loaded plugins successfully.')
except Exception as e:
self.logger.warning('[PluginManager] Plugin folder path not found. Error Message: {}'.format(str(e)))
def loadSinglePlugin(self, plugin_name): def loadSinglePlugin(self, plugin_name):
# TODO check already loaded plugin # TODO check already loaded plugin