diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-02-20 16:54:08 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-02-20 16:54:08 +0000 |
commit | e8c850f9a50485a53cc5a111cff5aced7233c112 (patch) | |
tree | ab5f8df7c6e1865c83f6ccbe9892cbfcf69b9a00 | |
parent | 7d12cee3841dec99e2af3073a8ba499492242534 (diff) | |
download | lorry-controller-e8c850f9a50485a53cc5a111cff5aced7233c112.tar.gz |
Fix lorry-controller.conf filename
Also, reorder code so the actual reading is in a method, to make run()
cleaner.
-rwxr-xr-x | lorry-controller-webapp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lorry-controller-webapp b/lorry-controller-webapp index f1d6456..ab4e343 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -180,11 +180,7 @@ class ReadConfiguration(LorryControllerRoute): 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) + conf_obj = self.read_config_file() troves = [x for x in conf_obj if x['type'] == 'trove'] lorries = [x for x in conf_obj if x['type'] == 'lorries'] @@ -195,6 +191,15 @@ class ReadConfiguration(LorryControllerRoute): # will return something reasonable-looking. return { 'troves': troves, 'lorries': lorries } + def read_config_file(self): + '''Read the configuration file, return as Python object.''' + + filename = os.path.join( + self.app_settings['configuration-directory'], + 'lorry-controller.conf') + with open(filename) as f: + return json.load(f) + class ListQueue(LorryControllerRoute): |