def connection_settings(): connectionOptions = printerManager().getConnectionOptions() if connectionOptions: plugins = pluginManager().getPluginsByProvider('printerComms') driverChoices = {("plugin:%s" % k): plugins[k].definition['name'] for k in plugins} driverChoices.update({ 'marlin': 'GCODE - Marlin / Repetier Firmware', 's3g': 'X3G - Sailfish / Makerbot Firmware' }) response = { "driver": printerProfileManager().data['driver'], "driverChoices": driverChoices, "port": connectionOptions["portPreference"], "baudrate": connectionOptions["baudratePreference"], "portOptions": connectionOptions["ports"].items(), "baudrateOptions": connectionOptions["baudrates"] } return jsonify(response) return make_response("Connection options not available", 400)
def installSoftwarePlugin(): data = request.json file = data.get('file', None) if file: pm = pluginManager() if pm.installFile(file): return jsonify() else: return make_response('Unable to Install', 500) return make_response('Invalid Request', 400)
def driverChoices(self): plugins = pluginManager().getPluginsByProvider('printerComms') result = { ("plugin:%s" % k) : { 'name': plugins[k].definition['name'], 'properties': plugins[k].settingsProperties } for k in plugins } result.update({ 'marlin': {'name': 'GCODE - Marlin / Repetier Firmware', 'properties': {'customCancelCommands': True}}, 's3g': {'name': 'X3G - Sailfish / Makerbot Firmware', 'properties': {'customCancelCommands': False}} }) return result
def __init__(self, pluginId): #Register to plugin remove events pm = pluginManager() self._plugin = pm.getPlugin(pluginId) if self._plugin is None: raise NoPluginException self._plugin.initPrinterCommsService(self) pm.addEventListener('ON_PLUGIN_REMOVED', self.onPluginRemoved) super(PrinterWithPlugin, self).__init__()
def getLicenseInfo(): pm = pluginManager() lcnMgr = pm.getPlugin('com.astroprint.astrobox.plugins.lcnmgr') if lcnMgr and lcnMgr.validLicense: return jsonify({ 'is_valid': True, 'issuer': lcnMgr.issuerName, 'expires': lcnMgr.expires, 'license_id': lcnMgr.licenseId }) return jsonify({'is_valid': False})
def uploadSoftwarePlugin(): if not "file" in request.files.keys(): return make_response("No file included", 400) file = request.files["file"] pm = pluginManager() r = pm.checkFile(file) if 'error' in r: return make_response(r['error'], 500) else: return jsonify(r)
def getSoftwarePlugins(): pm = pluginManager() response = [] for pId, p in pm.plugins.iteritems(): response.append({ 'id': p.pluginId, 'name': p.name, 'version': p.version, 'can_remove': not p.systemPlugin, 'verified': p.verified }) r = make_response(json.dumps(response), 200) r.headers['Content-Type'] = 'application/json' return r
def removeSoftwarePlugin(): data = request.json pId = data.get('id', None) if pId: pm = pluginManager() r = pm.removePlugin(pId) if 'error' in r: error = r['error'] if error == 'not_found': return make_response('Not Found', 404) else: return make_response(error, 500) else: return jsonify(r) return make_response('Invalid Request', 400)
def rampdown(self): pluginManager().removeEventListener('ON_PLUGIN_REMOVED', self.onPluginRemoved) super(PrinterWithPlugin, self).rampdown()