Skip to content

Commit 2dda3a0

Browse files
committed
Always run the GCodeAnalyser, even if the slicer provided analysis
The analysis from the Slicer or other sources is sent to the GCodeAnalyser, which can use it or ignore it. This fixes OctoPrint#2445 (comment) This fixes eyal0/OctoPrint-PrintTimeGenius#13
1 parent e239444 commit 2dda3a0

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ trim_trailing_whitespace = true
1111

1212
[**.py]
1313
indent_style = tab
14+
indent_size = 4
1415

1516
[src/octoprint/static/js/app/**.js]
1617
indent_style = space

src/octoprint/filemanager/__init__.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _determine_analysis_backlog(self, storage_type, storage_manager, root=None,
256256
file_name = storage_manager.split_path(path)
257257

258258
# we'll use the default printer profile for the backlog since we don't know better
259-
queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default())
259+
queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default(), None)
260260
if self._analysis_queue.enqueue(queue_entry, high_priority=high_priority):
261261
counter += 1
262262

@@ -476,12 +476,9 @@ def add_file(self, destination, path, file_object, links=None, allow_overwrite=F
476476

477477
path_in_storage = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite, display=display)
478478

479-
if analysis is None:
480-
queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile)
481-
if queue_entry:
482-
self._analysis_queue.enqueue(queue_entry, high_priority=True)
483-
else:
484-
self._add_analysis_result(destination, path, analysis)
479+
queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile, analysis=analysis)
480+
if queue_entry:
481+
self._analysis_queue.enqueue(queue_entry, high_priority=True)
485482

486483
_, name = self._storage(destination).split_path(path_in_storage)
487484
eventManager().fire(Events.FILE_ADDED, dict(storage=destination,
@@ -700,7 +697,7 @@ def _add_analysis_result(self, destination, path, result):
700697
def _on_analysis_finished(self, entry, result):
701698
self._add_analysis_result(entry.location, entry.path, result)
702699

703-
def _analysis_queue_entry(self, destination, path, printer_profile=None):
700+
def _analysis_queue_entry(self, destination, path, printer_profile=None, analysis=None):
704701
if printer_profile is None:
705702
printer_profile = self._printer_profile_manager.get_current_or_default()
706703

@@ -709,6 +706,6 @@ def _analysis_queue_entry(self, destination, path, printer_profile=None):
709706
file_type = get_file_type(absolute_path)
710707

711708
if file_type:
712-
return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile)
709+
return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile, analysis)
713710
else:
714711
return None

src/octoprint/filemanager/analysis.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from octoprint.settings import settings
2121

2222

23-
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile")):
23+
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
2424
"""
2525
A :class:`QueueEntry` for processing through the :class:`AnalysisQueue`. Wraps the entry's properties necessary
2626
for processing.
@@ -33,6 +33,7 @@ class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, locatio
3333
location (str): Location the file is located on.
3434
absolute_path (str): Absolute path on disk through which to access the file.
3535
printer_profile (PrinterProfile): :class:`PrinterProfile` which to use for analysis.
36+
analysis (dict): :class:`GcodeAnalysisQueue` results from prior analysis, or ``None`` if there is none.
3637
"""
3738

3839
def __str__(self):
@@ -341,6 +342,8 @@ def _do_analysis(self, high_priority=False):
341342
import sys
342343
import yaml
343344

345+
if self._current.analysis:
346+
return self._current.analysis
344347
try:
345348
throttle = settings().getFloat(["gcodeAnalysis", "throttle_highprio"]) if high_priority \
346349
else settings().getFloat(["gcodeAnalysis", "throttle_normalprio"])

0 commit comments

Comments
 (0)