Fix of file type detection

This commit is contained in:
Gina Häußge 2014-10-29 12:17:26 +01:00
parent 0aac7813e4
commit f8955c0d1b
2 changed files with 8 additions and 5 deletions

View file

@ -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

View file

@ -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