From e8c850f9a50485a53cc5a111cff5aced7233c112 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 20 Feb 2014 16:54:08 +0000 Subject: Fix lorry-controller.conf filename Also, reorder code so the actual reading is in a method, to make run() cleaner. --- lorry-controller-webapp | 15 ++++++++++----- 1 file 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): -- cgit v1.2.1