Move plugin listing into config

This commit is contained in:
Joshua Hesketh 2013-07-26 16:47:32 +10:00
parent 154f44144e
commit 6b6700b0a9
2 changed files with 11 additions and 6 deletions

View File

@ -6,5 +6,6 @@
},
"debug_log": "/home/josh/var/log/turbo-hipster/debug.log",
"git_working_dir": "/home/josh/var/lib/turbo-hipster/git/",
"job_log_dir": "/home/josh/var/lib/turbo-hipster/logs/"
"job_log_dir": "/home/josh/var/lib/turbo-hipster/logs/",
"plugins": ["gate_real_db_upgrade"]
}

View File

@ -42,6 +42,8 @@ class Server(object):
def setup_logging(self):
if self.debug_log:
if not os.path.isdir(os.path.dirname(self.debug_log)):
os.makedirs(os.path.dirname(self.debug_log))
logging.basicConfig(format='%(asctime)s %(message)s',
filename=self.debug_log, level=logging.DEBUG)
else:
@ -52,11 +54,13 @@ class Server(object):
def load_plugins(self):
""" Load the available plugins from task_plugins """
# Load plugins
for ent in os.listdir('task_plugins'):
if (os.path.isdir('task_plugins/' + ent)
and os.path.isfile('task_plugins/' + ent + '/task.py')):
plugin_info = imp.find_module('task', ['task_plugins/' + ent])
self.plugins.append(imp.load_module('task', *plugin_info))
for plugin in self.config['plugins']:
print
plugin_info = imp.find_module('task',
[(os.path.dirname(
os.path.realpath(__file__)) +
'/task_plugins/' + plugin)])
self.plugins.append(imp.load_module('task', *plugin_info))
def run_tasks(self):
""" Run the tasks """