コード例 #1
0
ファイル: job.py プロジェクト: Booli/OctoPrint
def controlJob():
	if not printer.isOperational():
		return make_response("Printer is not operational", 409)

	valid_commands = {
		"start": [],
		"restart": [],
		"pause": [],
		"cancel": []
	}

	command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
	if response is not None:
		return response

	activePrintjob = printer.isPrinting() or printer.isPaused()

	if command == "start":
		if activePrintjob:
			return make_response("Printer already has an active print job, did you mean 'restart'?", 409)
		printer.startPrint()
	elif command == "restart":
		if not printer.isPaused():
			return make_response("Printer does not have an active print job or is not paused", 409)
		printer.startPrint()
	elif command == "pause":
		if not activePrintjob:
			return make_response("Printer is neither printing nor paused, 'pause' command cannot be performed", 409)
		printer.togglePausePrint()
	elif command == "cancel":
		if not activePrintjob:
			return make_response("Printer is neither printing nor paused, 'cancel' command cannot be performed", 409)
		printer.cancelPrint()
	return NO_CONTENT
コード例 #2
0
ファイル: control.py プロジェクト: NeighborGeek/OctoPrint
def printJobControl():
	if "command" in request.values.keys():
		if request.values["command"] == "start":
			printer.startPrint()
		elif request.values["command"] == "pause":
			printer.togglePausePrint()
		elif request.values["command"] == "cancel":
			printer.cancelPrint()
	return jsonify(SUCCESS)
コード例 #3
0
ファイル: control.py プロジェクト: zhenninglim/OctoPrint
def printJobControl():
    if "command" in request.values.keys():
        if request.values["command"] == "start":
            printer.startPrint()
        elif request.values["command"] == "pause":
            printer.togglePausePrint()
        elif request.values["command"] == "cancel":
            printer.cancelPrint()
    return jsonify(SUCCESS)
コード例 #4
0
def controlJob(request=None):
    if not printer.isOperational():
        return make_response("Printer is not operational", 409)

    valid_commands = {
        "start": [],
        "restart": [],
        "pause": [],
        "cancel": [],
        "stop": []  #add by kevin, for emergency stop
    }

    command, data, response = util.getJsonCommandFromRequest(
        request, valid_commands)
    if response is not None:
        return response

    activePrintjob = printer.isPrinting() or printer.isPaused()

    if command == "start":
        if activePrintjob:
            return make_response(
                "Printer already has an active print job, did you mean 'restart'?",
                409)
        printer.startPrint()
    elif command == "restart":
        if not printer.isPaused():
            return make_response(
                "Printer does not have an active print job or is not paused",
                409)
        printer.startPrint()
    elif command == "pause":
        if not activePrintjob:
            return make_response(
                "Printer is neither printing nor paused, 'pause' command cannot be performed",
                409)
        printer.togglePausePrint()
    elif command == "cancel":
        if not activePrintjob:
            return make_response(
                "Printer is neither printing nor paused, 'cancel' command cannot be performed",
                409)
        printer.cancelPrint()
    #add by kevin, for emergency stop
    elif "stop" == command:
        printer.stopPrint()
        if not activePrintjob:
            return make_response(
                "Printer is neither printing nor paused, 'cancel' command cannot be performed",
                409)
        printer.cancelPrint()
    #add end, stop
    return NO_CONTENT
コード例 #5
0
ファイル: control.py プロジェクト: TopherMan/OctoPrint
def controlJob():
	if not printer.isOperational():
		return make_response("Printer is not operational", 403)

	valid_commands = {
		"start": [],
		"pause": [],
		"cancel": []
	}

	command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
	if response is not None:
		return response

	if command == "start":
		printer.startPrint()
	elif command == "pause":
		printer.togglePausePrint()
	elif command == "cancel":
		printer.cancelPrint()
	return jsonify(SUCCESS)