summaryrefslogtreecommitdiff
path: root/lorrycontroller/confparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/confparser.py')
-rw-r--r--lorrycontroller/confparser.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/lorrycontroller/confparser.py b/lorrycontroller/confparser.py
index b78dc54..188ac6b 100644
--- a/lorrycontroller/confparser.py
+++ b/lorrycontroller/confparser.py
@@ -34,12 +34,16 @@ class LorryControllerConfig(object):
self.duetimes = {}
self.troves = []
confpath = os.path.join(app.settings['work-area'], confpath)
- logging.debug("Parsing configuration: %s" % confpath)
- with open(confpath, "r") as fh:
- self._raw_conf = json.load(fh)
+ logging.info("Parsing configuration: %s" % confpath)
+ try:
+ with open(confpath, "r") as fh:
+ self._raw_conf = json.load(fh)
+ except Exception, e:
+ logging.error("Unable to parse: %r" % e)
+ raise
logging.debug("Validating configuration semantics")
self._validate__raw_conf()
- logging.debug("Configuration loaded")
+ logging.info("Configuration loaded")
def _validate__raw_conf(self):
'''Validate the entire raw config.'''
@@ -127,16 +131,16 @@ class LorryControllerConfig(object):
try:
with open(lorry, "r") as fh:
lorry_json = json.load(fh)
- for name, content in lorry_json.iteritems():
- fullname = os.path.join(entry['prefix'], name)
- if self.lorries.get(fullname, None) is not None:
- self._give_up("Lorry repeated: %s" % fullname)
- content['controller-uuid'] = entry['uuid']
- my_lorry_names.add(fullname)
- self.lorries[fullname] = content
+ for name, content in lorry_json.iteritems():
+ fullname = os.path.join(entry['prefix'], name)
+ if self.lorries.get(fullname, None) is not None:
+ self._give_up("Lorry repeated: %s" % fullname)
+ content['controller-uuid'] = entry['uuid']
+ my_lorry_names.add(fullname)
+ self.lorries[fullname] = content
except Exception, e:
- logging.debug("Unable to parse %s, because of %s. Moving on" %
- (lorry, e))
+ logging.warning("Unable to parse %s, because of %s. "
+ "Moving on" % (lorry, e))
# Now calculate the 'next due' time for every lorry we just parsed
starttime = time.time() - 1
@@ -180,8 +184,8 @@ class LorryControllerConfig(object):
self.troves.append(entry)
def update_trove(self, trove, state):
- logging.debug("Processing trove %s (%s)" % (trove['trovehost'],
- trove['uuid']))
+ logging.info("Processing trove %s (%s)" % (trove['trovehost'],
+ trove['uuid']))
# 1. Ensure that if we need to 'ls' the trove, we do it
now = time.time()
listcmdargs = ["ssh", "-oStrictHostKeyChecking=no",