MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / GcodeMetadataAnalyzer

Class GcodeMetadataAnalyzer

src/astroprint/printfiles/gcode.py:31–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 super(PrintFileManagerGcode, self).__init__()
30
31class 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
67class GcodeInterpreter(object):
68 def __init__(self,loadedCallback,currentFile):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected