From 0a040439221676c719e765009ea3327b92ba5091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Apr 2019 16:55:35 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20potential=20division=20by?= =?UTF-8?q?=20zero?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3116 --- src/octoprint/printer/estimation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/printer/estimation.py b/src/octoprint/printer/estimation.py index 91bff26c6..9bf5b0255 100644 --- a/src/octoprint/printer/estimation.py +++ b/src/octoprint/printer/estimation.py @@ -226,14 +226,14 @@ class TimeEstimationHelper(object): @property def average_total_rolling(self): - if not self._count or self._count < self._rolling_window: + if not self._count or self._count < self._rolling_window or not len(self._totals): return None else: return sum(self._totals) / len(self._totals) @property def average_distance(self): - if not self._count or self._count < self._rolling_window + 1: + if not self._count or self._count < self._rolling_window + 1 or not len(self._distances): return None else: return sum(self._distances) / len(self._distances)