| 29 | super(PrintFileManagerGcode, self).__init__() |
| 30 | |
| 31 | class GcodeMetadataAnalyzer(MetadataAnalyzer): |
| 32 | def __init__(self, getPathCallback, loadedCallback): |
| 33 | self._logger = logging.getLogger(__name__) |
| 34 | |
| 35 | self._gcode = None |
| 36 | |
| 37 | super(GcodeMetadataAnalyzer, self).__init__(getPathCallback, loadedCallback) |
| 38 | |
| 39 | def pause(self): |
| 40 | super(GcodeMetadataAnalyzer, self).pause() |
| 41 | |
| 42 | if self._gcode is not None: |
| 43 | self._logger.debug("Aborting running analysis, will restart when Gcode analyzer is resumed") |
| 44 | self._gcode.abort() |
| 45 | |
| 46 | def _analyzeFile(self, filename): |
| 47 | path = self._getPathCallback(filename) |
| 48 | |
| 49 | if path is None or not os.path.exists(path): |
| 50 | return |
| 51 | |
| 52 | self._currentFile = filename |
| 53 | self._currentProgress = 0 |
| 54 | |
| 55 | try: |
| 56 | self._logger.debug("Starting analysis of file %s" % filename) |
| 57 | eventManager().fire(Events.METADATA_ANALYSIS_STARTED, {"file": filename}) |
| 58 | self._gcode = GcodeInterpreter(self._loadedCallback,self._currentFile) |
| 59 | self._gcode.progressCallback = self._onParsingProgress |
| 60 | self._gcode.load(path) |
| 61 | |
| 62 | finally: |
| 63 | self._gcode = None |
| 64 | self._currentProgress = None |
| 65 | self._currentFile = None |
| 66 | |
| 67 | class GcodeInterpreter(object): |
| 68 | def __init__(self,loadedCallback,currentFile): |