Connecting to octoprint with the API interface, selecting a file and having it print immediately.
Looking for the 409 response code when there is already a print in progress (documentation says anytime it's not Operational when the request is made it should return 409)
Returns 204 even when in the middle of a print job
Code being used;
def print_file(directory,file): # Sends print job to ocotpi
url = "http://" + str(OCTOPI) + "/api/files/local/" + str(directory) + str(file) + "?apikey=" + str(OCTO_KEY)
post_values = {
'command':'select',
'print':True,
}
run_request = requests.post(url, json = post_values)
result = run_request.status_code
return(result)
test code for checking that 409 is returned:
for i in range(10):
print(print_file('Utility_Prints/','extents_square_v2.gcode'))
time.sleep(1)
Expected 409 code returned
had 204 code return
Yes
1.4.0
OctoPi 0.17.0
grbl custom plotter
python in command line on OSX
I have read the FAQ.
Yes
"not operational" means not connected. It's also operational when it's already printing, so the behaviour here is as documented.
However, that behaviour is suboptimal, it should in fact return a 409 not only when the printer isn't operational but also when it already has an active print job and not just fail in selecting and printing silently. Will adjust implementation and docs accordingly.
Solved by the above commit, to be released with 1.4.1.
Thank you for taking a look! That's a great resolution.
Most helpful comment
Thank you for taking a look! That's a great resolution.