diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index 6c27752a..1d73288b 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -200,9 +200,11 @@ class FileManager(object): if dest_job_key in self._slicing_jobs: del self._slicing_jobs[dest_job_key] + slicer = self._slicing_manager.get_slicer(slicer_name) + import time start_time = time.time() - eventManager().fire(Events.SLICING_STARTED, {"stl": source_path, "gcode": dest_path}) + eventManager().fire(Events.SLICING_STARTED, {"stl": source_path, "gcode": dest_path, "progressAvailable": slicer.get_slicer_properties()["progress_report"] if slicer else False}) import tempfile f = tempfile.NamedTemporaryFile(suffix=".gco", delete=False) @@ -266,10 +268,11 @@ class FileManager(object): def add_file(self, destination, path, file_object, links=None, allow_overwrite=False): file_path = self._storage(destination).add_file(path, file_object, links=links, allow_overwrite=allow_overwrite) absolute_path = self._storage(destination).get_absolute_path(file_path) - file_type = get_file_type(file_path)[-1] - queue_entry = QueueEntry(file_path, file_type, destination, absolute_path) - self._analysis_queue.enqueue(queue_entry, high_priority=True) + file_type = get_file_type(absolute_path) + if file_type: + queue_entry = QueueEntry(file_path, file_type[-1], destination, absolute_path) + self._analysis_queue.enqueue(queue_entry, high_priority=True) eventManager().fire(Events.UPDATED_FILES, dict(type="printables")) return file_path diff --git a/tests/filemanager/test_filemanager.py b/tests/filemanager/test_filemanager.py index a7f1ddca..4201ac23 100644 --- a/tests/filemanager/test_filemanager.py +++ b/tests/filemanager/test_filemanager.py @@ -157,7 +157,7 @@ class FileManagerTest(unittest.TestCase): self.file_manager.slice("some_slicer", octoprint.filemanager.FileDestinations.LOCAL, "source.file", octoprint.filemanager.FileDestinations.LOCAL, "dest.file", callback=callback, callback_args=callback_args) # assert that events where fired - expected_events = [mock.call(octoprint.filemanager.Events.SLICING_STARTED, {"stl": "source.file", "gcode": "dest.file"}), + expected_events = [mock.call(octoprint.filemanager.Events.SLICING_STARTED, {"stl": "source.file", "gcode": "dest.file", "progressAvailable": False}), mock.call(octoprint.filemanager.Events.SLICING_DONE, {"stl": "source.file", "gcode": "dest.file", "time": 15.694000005722046})] self.fire_event.call_args_list = expected_events