From d3626d97e93f9a7f89a190bc9cee771020c0f991 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Tue, 9 Dec 2014 13:49:21 +0000 Subject: Make plugin loading work properly --- turbo_hipster/worker_server.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/turbo_hipster/worker_server.py b/turbo_hipster/worker_server.py index c59c2ef..c3db2b9 100644 --- a/turbo_hipster/worker_server.py +++ b/turbo_hipster/worker_server.py @@ -17,6 +17,7 @@ import logging import os +import sys import threading import yaml @@ -118,12 +119,16 @@ class Server(threading.Thread): if 'plugins' in self.config: for plugin in self.config['plugins']: try: - if plugin['pythonpath'] not in sys.path: - sys.path.append(plugin['pythonpath']) - module = __import__('turbo_hipster.task_plugins.' + - plugin['name'] + '.task', - fromlist='turbo_hipster.task_plugins' + - plugin['name']) + if plugin['location'] not in sys.path: + sys.path.append(plugin['location']) + if plugin['import-path']: + module = __import__(plugin['import-path'], + fromlist='.'.join(plugin['import-path'].split('.')[:-1])) + else: + module = __import__('turbo_hipster.task_plugins.' + + plugin['name'] + '.task', + fromlist='turbo_hipster.task_plugins' + + plugin['name']) self.jobs[plugin['function']] = { 'name': plugin['function'], -- cgit v1.2.1