From 81e1ad2ee7c1e1633bad05ecf633d1e12e75652b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 24 Apr 2020 18:11:23 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Only=20use=20supplied=20analysis?= =?UTF-8?q?=20if=20it's=20complete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We might not get the full set of data we want from the add_file call and thus need to enrich the data further with our own analysis results. Whatever we get supplied from the caller will always win. --- src/octoprint/filemanager/analysis.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/octoprint/filemanager/analysis.py b/src/octoprint/filemanager/analysis.py index e945752b5..9f04f2183 100644 --- a/src/octoprint/filemanager/analysis.py +++ b/src/octoprint/filemanager/analysis.py @@ -19,7 +19,7 @@ import time from octoprint.events import Events, eventManager from octoprint.settings import settings from octoprint.util import monotonic_time -from octoprint.util import get_fully_qualified_classname as fqcn +from octoprint.util import get_fully_qualified_classname as fqcn, dict_merge from octoprint.util.platform import CLOSE_FDS @@ -346,8 +346,12 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): import sys import yaml - if self._current.analysis: + if self._current.analysis and all(map(lambda x: x in self._current.analysis, ("printingArea", + "dimensions", + "estimatedPrintTime", + "filament"))): return self._current.analysis + try: throttle = settings().getFloat(["gcodeAnalysis", "throttle_highprio"]) if high_priority \ else settings().getFloat(["gcodeAnalysis", "throttle_normalprio"]) @@ -422,7 +426,11 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): "length": analysis["extrusion_length"][i], "volume": analysis["extrusion_volume"][i] } - return result + + if self._current.analysis and isinstance(self._current.analysis, dict): + return dict_merge(result, self._current.analysis) + else: + return result finally: self._gcode = None