diff options
Diffstat (limited to 'lorrycontroller/status.py')
-rw-r--r-- | lorrycontroller/status.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lorrycontroller/status.py b/lorrycontroller/status.py index 8483485..df39470 100644 --- a/lorrycontroller/status.py +++ b/lorrycontroller/status.py @@ -29,19 +29,24 @@ class StatusRenderer(object): '''Helper class for rendering service status as JSON/HTML''' - def get_status_as_dict(self, statedb, work_directory): + def get_queue_status_as_dict(self, statedb): now = statedb.get_current_time() - status = { - 'running_queue': statedb.get_running_queue(), + return { 'timestamp': time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(now)), 'run_queue': self.get_run_queue(statedb), + } + + def get_status_as_dict(self, statedb, work_directory): + status = self.get_queue_status_as_dict(statedb) + status.update({ + 'running_queue': statedb.get_running_queue(), 'hosts': self.get_hosts(statedb), 'warning_msg': '', 'max_jobs': self.get_max_jobs(statedb), 'links': True, 'publish_failures': True, - } + }) status.update(self.get_free_disk_space(work_directory)) return status @@ -209,3 +214,17 @@ class StatusHTML(lorrycontroller.LorryControllerRoute): self.app_settings['publish-failures']) return renderer.render_status_as_html( self._templates['status'], status) + + +class FailuresHTML(lorrycontroller.LorryControllerRoute): + + http_method = 'GET' + path = '/1.0/failures-html' + + def run(self, **kwargs): + logging.info('%s %s called', self.http_method, self.path) + renderer = StatusRenderer() + with self.open_statedb() as statedb: + status = renderer.get_queue_status_as_dict(statedb) + return renderer.render_status_as_html( + self._templates['failures'], status) |