--printer-status does not return the correct string
Closed this issue · 3 comments
jak0lantash commented
Octoprint Version 1.3.11
$ python3 ./octo-control.py --apikey FAE84B5938824EEE8D347C4E0F3110B0 --host localhost --port 5000 --printer-status
"Printing
I don't know much in python, but it looks like cutting the string at ':' is not sufficient to remove the JSON format property: "value"
return line[line.find(':')+1:line.find(',')]
jak0lantash commented
Instead of browsing the response lines and parsing the text, it seems that using the json module is far easier. That said, I don't know python yet. I guess this is a good opportunity to learn, so I'll try to contribute here.
This works to get the printer status
json.loads(r.content.decode('utf-8'))["state"]["text"]
dragondgold commented
Hi @jak0lantash! As you point out, the JSON module is the right way to do it, I was really new to Python back then. Submit a pull request with the change please! :)
jak0lantash commented
Closing this issue since PR complete