Пример #1
0
def saveNozzle():

    if not printer.is_operational():
        return make_response("Printer is not operational", 409)

    valid_commands = {"nozzle": ["nozzleType"]}
    command, data, response = get_json_command_from_request(
        request, valid_commands)
    if response is not None:
        return response

    nozzle = data['nozzleType']

    if not printer.isValidNozzleSize(nozzle):
        return make_response("Invalid nozzle size", 409)

    # converts the nozzle to integer
    nozzle = int(nozzle * 1000)
    resp = printer.setNozzleSize(nozzle)

    printer_profile = printerProfileManager.get_current()
    if printer_profile is not None:
        printer_profile['extruder']['nozzleDiameter'] = nozzle
        printerProfileManager.save(printer_profile, allow_overwrite=True)
    else:
        return jsonify(
            {"response": "Could not find printer profile for saving."})

    return jsonify({"response": resp})
def _etag(lm=None):
    if lm is None:
        lm = _lastmodified()

    import hashlib
    hash = hashlib.sha1()
    hash.update(str(lm))
    hash.update(repr(printerProfileManager.get_default()))
    hash.update(repr(printerProfileManager.get_current()))
    return hash.hexdigest()
Пример #3
0
def _etag(lm=None):
	if lm is None:
		lm = _lastmodified()

	import hashlib
	hash = hashlib.sha1()
	hash.update(str(lm))
	hash.update(repr(printerProfileManager.get_default()))
	hash.update(repr(printerProfileManager.get_current()))
	return hash.hexdigest()
Пример #4
0
def printerProfilesDelete(identifier):
	current_profile = printerProfileManager.get_current()
	if current_profile and current_profile["id"] == identifier:
		return make_response("Cannot delete currently selected profile: {}".format(identifier), 409)

	default_profile = printerProfileManager.get_default()
	if default_profile and default_profile["id"] == identifier:
		return make_response("Cannot delete default profile: {}".format(identifier), 409)

	printerProfileManager.remove(identifier)
	return NO_CONTENT
Пример #5
0
def printerProfilesDelete(identifier):
    current_profile = printerProfileManager.get_current()
    if current_profile and current_profile["id"] == identifier:
        abort(409, description="Cannot delete currently selected profile")

    default_profile = printerProfileManager.get_default()
    if default_profile and default_profile["id"] == identifier:
        abort(409, description="Cannot delete default profile")

    printerProfileManager.remove(identifier, trigger_event=True)
    return NO_CONTENT