diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-02-20 15:13:48 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-02-20 15:13:48 +0000 |
commit | 2c0565e265f2141002f955eca880b71c1487f43a (patch) | |
tree | f740b8e910889505e5f7f228b027633d1e591342 | |
parent | 0e11590cad69f4d967fb30fb78aa4a27992b2153 (diff) | |
download | lorry-controller-2c0565e265f2141002f955eca880b71c1487f43a.tar.gz |
Add start of CONFGIT reading
-rwxr-xr-x | lorry-controller-webapp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lorry-controller-webapp b/lorry-controller-webapp index e37420b..f1d6456 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -17,6 +17,7 @@ import logging +import json import os import sqlite3 import time @@ -171,6 +172,41 @@ class StatusHTML(LorryControllerRoute): return renderer.render_status_as_html(status) +class ReadConfiguration(LorryControllerRoute): + + http_method = 'GET' + path = '/1.0/read-configuration' + + def run(self, **kwargs): + # FIXME: This doesn't update the git repo from upstream, yet. + + filename = os.path.join( + self.app_settings['configuration-directory'], + 'trove.conf') + with open(filename) as f: + conf_obj = json.load(f) + troves = [x for x in conf_obj if x['type'] == 'trove'] + lorries = [x for x in conf_obj if x['type'] == 'lorries'] + + # FIXME: put the troves and the lorries into STATEDB, but + # don't generate lorries from troves, yet. Don't, in fact, + # scan for local lorries either, yet. Just make sure STATEDB + # has the right tables and columns so that /1.0/list-queue + # will return something reasonable-looking. + return { 'troves': troves, 'lorries': lorries } + + +class ListQueue(LorryControllerRoute): + + http_method = 'GET' + path = '/1.0/list-queue' + + def run(self, **kwargs): + return { + 'queue': [], + } + + class StartQueue(LorryControllerRoute): http_method = 'GET' @@ -200,6 +236,12 @@ class WEBAPP(cliapp.Application): metavar='FILE') self.settings.string( + ['configuration-directory'], + 'use DIR as the configuration directory', + metavar='DIR', + default='.') + + self.settings.string( ['status-html'], 'write a static HTML page to FILE to describe overall status', metavar='FILE', |