|
|
@ -24,7 +24,6 @@ class Loader(object): |
|
|
|
self.addPath(root, base_path + [filename], priority, recursive = True) |
|
|
|
|
|
|
|
def preload(self, root = ''): |
|
|
|
|
|
|
|
core = os.path.join(root, 'couchpotato', 'core') |
|
|
|
|
|
|
|
self.paths = { |
|
|
@ -58,7 +57,10 @@ class Loader(object): |
|
|
|
if plugin.get('name')[:2] == '__': |
|
|
|
continue |
|
|
|
|
|
|
|
m = getattr(self.loadModule(module_name), plugin.get('name')) |
|
|
|
m = self.loadModule(module_name) |
|
|
|
if m is None: |
|
|
|
continue |
|
|
|
m = getattr(m, plugin.get('name')) |
|
|
|
|
|
|
|
log.info('Loading %s: %s', (plugin['type'], plugin['name'])) |
|
|
|
|
|
|
@ -101,6 +103,9 @@ class Loader(object): |
|
|
|
self.addModule(priority, plugin_type, module_name, name) |
|
|
|
|
|
|
|
def loadSettings(self, module, name, save = True): |
|
|
|
if not hasattr(module, 'config'): |
|
|
|
log.warning('Skip loading settings for plugin %s as it has no config section' % module.__file__) |
|
|
|
return False |
|
|
|
try: |
|
|
|
for section in module.config: |
|
|
|
fireEvent('settings.options', section['name'], section) |
|
|
@ -115,6 +120,9 @@ class Loader(object): |
|
|
|
return False |
|
|
|
|
|
|
|
def loadPlugins(self, module, name): |
|
|
|
if not hasattr(module, 'start'): |
|
|
|
log.warning('Skip startup for plugin %s as it has no start section' % module.__file__) |
|
|
|
return False |
|
|
|
try: |
|
|
|
module.start() |
|
|
|
return True |
|
|
@ -141,5 +149,8 @@ class Loader(object): |
|
|
|
for sub in splitted[1:-1]: |
|
|
|
m = getattr(m, sub) |
|
|
|
return m |
|
|
|
except ImportError: |
|
|
|
log.warning("Skip loading module plugin '%s' as it seems not to be a module." % name) |
|
|
|
return None |
|
|
|
except: |
|
|
|
raise |
|
|
|