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 | 603 | else: |
604 | 604 | estimation_output = estimation.get_output_dict() |
605 | 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 | 610 | return render_template( |
610 | 611 | "estimation.html", | ... | ... |
flaskr/models.py
... | ... | @@ -71,9 +71,11 @@ class Estimation(db.Model): |
71 | 71 | |
72 | 72 | def get_output_dict(self): |
73 | 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 | 78 | return self._output_dict |
76 | - pass | |
77 | 79 | |
78 | 80 | def is_one_to_one(self): |
79 | 81 | return self.scenario == ScenarioEnum.one_to_one | ... | ... |