Warn user when luigi is not installed, for relevant view
better than getting a server error
This commit is contained in:
parent
6fbc79fe5e
commit
8a6fdb5ea5
|
@ -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()
|
||||
|
||||
# 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):
|
||||
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):
|
||||
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'])
|
||||
|
|
Loading…
Reference in a new issue