Example #1
0
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)
Example #2
0
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)
Example #3
0
	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
Example #4
0
    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__()
Example #5
0
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})
Example #6
0
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)
Example #7
0
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
Example #8
0
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)
Example #9
0
 def rampdown(self):
     pluginManager().removeEventListener('ON_PLUGIN_REMOVED',
                                         self.onPluginRemoved)
     super(PrinterWithPlugin, self).rampdown()