Skip to content

octoprint.filemanager.analysis#

AbstractAnalysisQueue(finished_callback) #

The AbstractAnalysisQueue is the parent class of all specific analysis queues such as the GcodeAnalysisQueue. It offers methods to enqueue new entries to analyze and pausing and resuming analysis processing.

Initializes the queue.

Parameters:

  • finished_callback (callable) –

    Callback that will be called upon finishing analysis of an entry in the queue. The callback will be called with the analyzed entry as the first argument and the analysis result as returned from the queue implementation as the second parameter.

_do_abort(reenqueue = True) #

Aborts analysis of the current entry. Needs to be overridden by sub classes.

_do_analysis(high_priority = False) #

Performs the actual analysis of the current entry which can be accessed via self._current. Needs to be overridden by sub classes.

Parameters:

  • high_priority (bool) –

    Whether the current entry has high priority or not.

Returns:

  • object

    The result of the analysis which will be forwarded to the finished_callback provided during construction.

enqueue(entry, high_priority = False) #

Enqueues an entry for analysis by the queue.

If high_priority is True (defaults to False), the entry will be prioritized and hence processed before other entries in the queue with normal priority.

Parameters:

  • entry (QueueEntry) –

    The entry to analyze.

  • high_priority (bool) –

    Whether to process the provided entry with high priority (True) or not (False, default)

pause() #

Pauses processing of the queue, e.g. when a print is active.

resume() #

Resumes processing of the queue, e.g. when a print has finished.

AnalysisQueue(queue_factories) #

OctoPrint's AnalysisQueue can manage various AbstractAnalysisQueue implementations, mapped by their machine code type.

By invoking [register_finish_callback][octoprint.filemanager.analysis.AnalysisQueue.register_finish_callback] it is possible to register oneself as a callback to be invoked each time the analysis of a queue entry finishes. The call parameters will be the finished queue entry as the first and the analysis result as the second parameter. It is also possible to remove the registration again by invoking [unregister_finish_callback][octoprint.filemanager.analysis.AnalysisQueue.unregister_finish_callback].

[enqueue][octoprint.filemanager.analysis.AnalysisQueue.enqueue] allows enqueuing QueueEntry instances to analyze. If the [QueueEntry.type][octoprint.filemanager.analysis.QueueEntry.type] is unknown (no specific child class of AbstractAnalysisQueue is registered for it), nothing will happen. Otherwise the entry will be enqueued with the type specific analysis queue.

GcodeAnalysisQueue(finished_callback) #

Bases: AbstractAnalysisQueue

A queue to analyze GCODE files. Analysis results are dict instances structured as follows:

Name Type Description
estimatedPrintTime int Estimated time the file take to print, in seconds
filament.* dict Substructure describing estimated filament usage. Keys are tool0 for the first extruder, tool1 for the second and so on. For each tool extruded length and volume (based on diameter) are provided.
filament.toolX.length float The extruded length in mm
filament.toolX.volume float The extruded volume in cm³
printingArea.* dict Bounding box of the printed object in the print volume (minimum and maximum coordinates)
printingArea.minX float Minimum X coordinate of the printed object
printingArea.maxX float Maximum X coordinate of the printed object
printingArea.minY float Minimum Y coordinate of the printed object
printingArea.maxY float Maximum Y coordinate of the printed object
printingArea.minZ float Minimum Z coordinate of the printed object
printingArea.maxZ float Maximum Z coordinate of the printed object
dimensions.* dict Dimensions of the printed object in X, Y, Z
dimensions.width float Width of the printed model along the X axis, in mm
dimensions.depth float Depth of the printed model along the Y axis, in mm
dimensions.height float Height of the printed model along the Z axis, in mm
travelArea.* dict Bounding box of all machine movements (minimum and maximum coordinates)
travelArea.minX float Minimum X coordinate of the machine movements
travelArea.maxX float Maximum X coordinate of the machine movements
travelArea.minY float Minimum Y coordinate of the machine movements
travelArea.maxY float Maximum Y coordinate of the machine movements
travelArea.minZ float Minimum Z coordinate of the machine movements
travelArea.maxZ float Maximum Z coordinate of the machine movements
travelDimensions.* dict Dimensions of the travel area in X, Y, Z
travelDimensions.width float Width of the travel area along the X axis, in mm
travelDimensions.depth float Depth of the travel area along the X axis, in mm
travelDimensions.height float Height of the travel area along the X axis, in mm

QueueEntry #

Bases: collections.namedtuple('QueueEntry', 'name, path, type, location, absolute_path, printer_profile, analysis')

A QueueEntry for processing through the AnalysisQueue. Wraps the entry's properties necessary for processing.

Parameters:

  • name (str) –

    Name of the file to analyze.

  • path (str) –

    Storage location specific path to the file to analyze.

  • type (str) –

    Type of file to analyze, necessary to map to the correct AbstractAnalysisQueue sub class. At the moment, only gcode is supported here.

  • location (str) –

    Location the file is located on.

  • absolute_path (str) –

    Absolute path on disk through which to access the file.

  • printer_profile (octoprint.printer.profile.PrinterProfile) –

    [PrinterProfile][octoprint.printer.profile.PrinterProfile] which to use for analysis.

  • analysis (dict) –

    GcodeAnalysisQueue results from prior analysis, or None if there is none.