Commit 37e28f2ccbc960f7a9a12796bb47c81de1de08ad
1 parent
e144bb1b
Exists in
master
Improve resilience.
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
flaskr/controllers/main_controller.py
@@ -603,8 +603,9 @@ def consult_estimation(public_id, extension): | @@ -603,8 +603,9 @@ def consult_estimation(public_id, extension): | ||
603 | else: | 603 | else: |
604 | estimation_output = estimation.get_output_dict() | 604 | estimation_output = estimation.get_output_dict() |
605 | estimation_sum = 0 | 605 | estimation_sum = 0 |
606 | - for city in estimation_output['cities']: | ||
607 | - estimation_sum += city['footprint'] | 606 | + if estimation_output: |
607 | + for city in estimation_output['cities']: | ||
608 | + estimation_sum += city['footprint'] | ||
608 | 609 | ||
609 | return render_template( | 610 | return render_template( |
610 | "estimation.html", | 611 | "estimation.html", |
flaskr/models.py
@@ -71,9 +71,11 @@ class Estimation(db.Model): | @@ -71,9 +71,11 @@ class Estimation(db.Model): | ||
71 | 71 | ||
72 | def get_output_dict(self): | 72 | def get_output_dict(self): |
73 | if self._output_dict is None: | 73 | if self._output_dict is None: |
74 | - self._output_dict = yaml_load(self.output_yaml) | 74 | + if self._output_yaml is None: |
75 | + self._output_dict = None | ||
76 | + else: | ||
77 | + self._output_dict = yaml_load(self.output_yaml) | ||
75 | return self._output_dict | 78 | return self._output_dict |
76 | - pass | ||
77 | 79 | ||
78 | def is_one_to_one(self): | 80 | def is_one_to_one(self): |
79 | return self.scenario == ScenarioEnum.one_to_one | 81 | return self.scenario == ScenarioEnum.one_to_one |