From 37e28f2ccbc960f7a9a12796bb47c81de1de08ad Mon Sep 17 00:00:00 2001 From: Antoine Goutenoir Date: Tue, 11 Feb 2020 11:09:43 +0100 Subject: [PATCH] Improve resilience. --- flaskr/controllers/main_controller.py | 5 +++-- flaskr/models.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/flaskr/controllers/main_controller.py b/flaskr/controllers/main_controller.py index bb77038..1380118 100644 --- a/flaskr/controllers/main_controller.py +++ b/flaskr/controllers/main_controller.py @@ -603,8 +603,9 @@ def consult_estimation(public_id, extension): else: estimation_output = estimation.get_output_dict() estimation_sum = 0 - for city in estimation_output['cities']: - estimation_sum += city['footprint'] + if estimation_output: + for city in estimation_output['cities']: + estimation_sum += city['footprint'] return render_template( "estimation.html", diff --git a/flaskr/models.py b/flaskr/models.py index 7900b54..3ba24ab 100755 --- a/flaskr/models.py +++ b/flaskr/models.py @@ -71,9 +71,11 @@ class Estimation(db.Model): def get_output_dict(self): if self._output_dict is None: - self._output_dict = yaml_load(self.output_yaml) + if self._output_yaml is None: + self._output_dict = None + else: + self._output_dict = yaml_load(self.output_yaml) return self._output_dict - pass def is_one_to_one(self): return self.scenario == ScenarioEnum.one_to_one -- libgit2 0.21.2