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

Function printerManager

src/astroprint/printer/manager.py:14–51  ·  view source on GitHub ↗
(driver = None)

Source from the content-addressed store, hash-verified

12# DO NOT store a reference to the result of printerManager in any persistant object.
13
14def printerManager(driver = None):
15 global _instance
16
17 if driver is not None and _instance is not None and _instance.driverName != driver:
18 _instance.rampdown()
19 _instance = None
20
21 if _instance is None and driver:
22 if driver.startswith('plugin:'):
23 from astroprint.printer.plugin import PrinterWithPlugin, NoPluginException
24
25 try:
26 _instance = PrinterWithPlugin(driver[7:])
27
28 except NoPluginException:
29 #The plugin is gone. Pick the default
30 from astroprint.printerprofile import printerProfileManager
31 ppm = printerProfileManager()
32 ppm.set({'driver': DEFAULT_MANAGER})
33 ppm.save()
34
35 else:
36 import importlib
37
38 try:
39 # driver name to class map. format is (module, classname)
40 classInfo = {
41 'marlin': ('.marlin', 'PrinterMarlin'),
42 's3g': ('.s3g', 'PrinterS3g')
43 }[driver]
44
45 except KeyError:
46 classInfo = ('.marlin', 'PrinterMarlin')
47
48 module = importlib.import_module(classInfo[0], 'astroprint.printer')
49 _instance = getattr(module, classInfo[1])()
50
51 return _instance

Callers 15

indexFunction · 0.90
getStatusFunction · 0.90
runMethod · 0.90
cleanupMethod · 0.90
on_openMethod · 0.90
on_closeMethod · 0.90
clearBedFunction · 0.90
controlJobFunction · 0.90
jobStateFunction · 0.90
getSettingsFunction · 0.90
restartServerMethod · 0.90
download_print_fileMethod · 0.90

Calls 5

rampdownMethod · 0.95
PrinterWithPluginClass · 0.90
printerProfileManagerFunction · 0.90
setMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected