diff --git a/tailbone/views/luigi.py b/tailbone/views/luigi.py index aaa7e2be..d340bfee 100644 --- a/tailbone/views/luigi.py +++ b/tailbone/views/luigi.py @@ -62,9 +62,22 @@ class LuigiTaskView(MasterView): def __init__(self, request, context=None): super(LuigiTaskView, self).__init__(request, context=context) app = self.get_rattail_app() - self.luigi_handler = app.get_luigi_handler() + + # nb. luigi may not be installed, which (for now) may prevent + # us from getting our handler; in which case warn user + try: + self.luigi_handler = app.get_luigi_handler() + except Exception as error: + self.luigi_handler = None + self.luigi_handler_error = error + log.warning("could not get luigi handler", exc_info=True) def index(self): + + if not self.luigi_handler: + self.request.session.flash("Could not create handler: {}".format( + simple_error(self.luigi_handler_error)), 'error') + luigi_url = self.rattail_config.get('rattail.luigi', 'url') history_url = '{}/history'.format(luigi_url.rstrip('/')) if luigi_url else None return self.render_to_response('index', { @@ -147,14 +160,20 @@ class LuigiTaskView(MasterView): return context def get_overnight_tasks(self): - tasks = self.luigi_handler.get_all_overnight_tasks() + if self.luigi_handler: + tasks = self.luigi_handler.get_all_overnight_tasks() + else: + tasks = [] for task in tasks: if task['last_date']: task['last_date'] = six.text_type(task['last_date']) return tasks def get_backfill_tasks(self): - tasks = self.luigi_handler.get_all_backfill_tasks() + if self.luigi_handler: + tasks = self.luigi_handler.get_all_backfill_tasks() + else: + tasks = [] for task in tasks: if task['last_date']: task['last_date'] = six.text_type(task['last_date'])