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

Function selectAndOrPrint

src/astroprint/api/files.py:150–160  ·  view source on GitHub ↗

Callback for when the file is ready to be selected and optionally printed. For SD file uploads this is only the case after they have finished streaming to the printer, which is why this callback is also used for the corresponding call to addSdFile. Selects the just uploaded file if either

(filename, absFilename, destination)

Source from the content-addressed store, hash-verified

148 return filename
149
150 def selectAndOrPrint(filename, absFilename, destination):
151 """
152 Callback for when the file is ready to be selected and optionally printed. For SD file uploads this is only
153 the case after they have finished streaming to the printer, which is why this callback is also used
154 for the corresponding call to addSdFile.
155
156 Selects the just uploaded file if either selectAfterUpload or printAfterSelect are True, or if the
157 exact file is already selected, such reloading it.
158 """
159 if selectAfterUpload or printAfterSelect or (currentFilename == filename and currentOrigin == destination):
160 printerManager().selectFile(absFilename, destination == FileDestinations.SDCARD, printAfterSelect)
161
162 try:
163 filename, done = printer.fileManager.addFile(file, target, fileProcessingFinished)

Callers 1

fileProcessingFinishedFunction · 0.85

Calls 2

printerManagerFunction · 0.90
selectFileMethod · 0.45

Tested by

no test coverage detected