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

Class PrinterWithPlugin

src/astroprint/printer/plugin/__init__.py:20–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 pass
19
20class PrinterWithPlugin(Printer):
21 driverName = 'plugin'
22
23 def __init__(self, pluginId):
24 self._comm = True # This isn't really used by this plugin but the parent class needs it
25
26 #Register to plugin remove events
27 pm = pluginManager()
28
29 self._plugin = pm.getPlugin(pluginId)
30 if self._plugin is None:
31 raise NoPluginException
32
33 self._plugin.initPrinterCommsService(self)
34
35 pm.addEventListener('ON_PLUGIN_REMOVED', self.onPluginRemoved)
36
37 super(PrinterWithPlugin, self).__init__()
38
39 def rampdown(self):
40 pluginManager().removeEventListener('ON_PLUGIN_REMOVED', self.onPluginRemoved)
41 super(PrinterWithPlugin, self).rampdown()
42
43 def getConnectionOptions(self):
44 """
45 Retrieves the available ports, baudrates, prefered port and baudrate for connecting to the printer.
46 """
47 s = settings()
48
49 return {
50 "ports": self.serialList(),
51 "baudrates": self.baudrateList(),
52 "portPreference": s.get(["serial", "port"]),
53 "baudratePreference": s.getInt(["serial", "baudrate"]),
54 "autoconnect": s.getBoolean(["serial", "autoconnect"])
55 }
56
57 @property
58 def allowTerminal(self):
59 return self._plugin.allowTerminal
60
61 @property
62 def _fileManagerClass(self):
63 return self._plugin.fileManagerClass
64
65 def doConnect(self, port, baudrate):
66 return self._plugin.connect(port, baudrate)
67
68 def doDisconnect(self):
69 return self._plugin.disconnect()
70
71 def getSdFiles(self):
72 pass
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')

Callers 1

printerManagerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected