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

Method selectFile

src/astroprint/printer/__init__.py:742–775  ·  view source on GitHub ↗
(self, filename, sd, printAfterSelect=False, printJobId=None)

Source from the content-addressed store, hash-verified

740 # ~~~ File Management ~~~~
741
742 def selectFile(self, filename, sd, printAfterSelect=False, printJobId=None):
743 if not self.isConnected() or self.isBusy() or self.isStreaming():
744 self._logger.info("Cannot load file: printer not connected or currently busy")
745 return False
746
747 self._setProgressData(0, None, None, None, 1)
748 self._setCurrentZ(None)
749
750 if not os.path.exists(filename) or not os.path.isfile(filename):
751 raise IOError("File %s does not exist" % filename)
752
753 filesize = os.stat(filename).st_size
754
755 eventManager().fire(Events.FILE_SELECTED, {
756 "file": filename,
757 "origin": FileDestinations.SDCARD if sd else FileDestinations.LOCAL
758 })
759
760 self._setJobData(filename, filesize, sd)
761 self.refreshStateData()
762
763 self._currentFile = {
764 'filename': filename,
765 'size': filesize,
766 'origin': FileDestinations.SDCARD if sd else FileDestinations.LOCAL,
767 'start_time': None,
768 'progress': None,
769 'position': None
770 }
771
772 if printAfterSelect:
773 self.startPrint(printJobId)
774
775 return True
776
777 def unselectFile(self):
778 self._currentFile = None

Callers 4

successCbMethod · 0.45
printFileMethod · 0.45
selectAndOrPrintFunction · 0.45
printFileCommandFunction · 0.45

Calls 10

isConnectedMethod · 0.95
isBusyMethod · 0.95
isStreamingMethod · 0.95
_setProgressDataMethod · 0.95
_setCurrentZMethod · 0.95
_setJobDataMethod · 0.95
refreshStateDataMethod · 0.95
startPrintMethod · 0.95
eventManagerFunction · 0.90
fireMethod · 0.80

Tested by

no test coverage detected