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

Method selectFile

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

Source from the content-addressed store, hash-verified

73 #return self._sdFiles
74
75 def selectFile(self, filename, sd, printAfterSelect=False, printJobId=None):
76 if sd and not self._plugin.allowSDCardPrinting:
77 raise('Printing from SD card is not supported on this printer')
78
79 if not super(PrinterWithPlugin, self).selectFile(filename, sd, printAfterSelect, printJobId):
80 return False
81
82 if not os.path.exists(filename) or not os.path.isfile(filename):
83 raise IOError("File %s does not exist" % filename)
84
85 filesize = os.stat(filename).st_size
86
87 eventManager().fire(Events.FILE_SELECTED, {
88 "file": filename,
89 "origin": FileDestinations.SDCARD if sd else FileDestinations.LOCAL
90 })
91
92 self._setJobData(filename, filesize, sd)
93 self.refreshStateData()
94
95 self._currentFile = {
96 'filename': filename,
97 'size': filesize,
98 'origin': FileDestinations.SDCARD if sd else FileDestinations.LOCAL,
99 'start_time': None,
100 'progress': None,
101 'position': None
102 }
103
104 if printAfterSelect:
105 self.startPrint()
106
107 return True
108
109 def startPrint(self, printJobId=None):
110 if not super(PrinterWithPlugin, self).startPrint(printJobId):

Callers

nothing calls this directly

Calls 5

startPrintMethod · 0.95
eventManagerFunction · 0.90
fireMethod · 0.80
refreshStateDataMethod · 0.80
_setJobDataMethod · 0.45

Tested by

no test coverage detected