A single-stepping GCODE tool

This commit is contained in:
Reid D. 'arrdem' McKenzie 2022-05-31 09:41:32 -06:00
parent bd3fe9bb00
commit 342b113cdb
2 changed files with 52 additions and 0 deletions

10
projects/octostep/BUILD Normal file
View file

@ -0,0 +1,10 @@
zapp_binary(
name = "octostep",
shebang = "/usr/bin/env /usr/bin/python3",
main = "__main__.py",
deps = [
py_requirement("colored"),
py_requirement("octorest"),
py_requirement("pyyaml"),
],
)

View file

@ -0,0 +1,42 @@
"""A quick and dirty octoprint status screen"""
from configparser import ConfigParser
import os
from octorest.client import OctoRest
if __name__ == "__main__":
config = ConfigParser()
config.read(os.path.expanduser("~/.config/octoprint-cli.ini"))
client = OctoRest(url="http://" + config["server"]["ServerAddress"],
apikey=config["server"]["ApiKey"])
for line in open(sys.argv[1], "r"):
l = line.split(";")[0]
l = l.strip()
if not l:
continue
while True:
print(f"\n> {l}")
cmd = input("[seq?] >>> ")
if cmd == "s":
client.gcode(l)
break
elif cmd == "e":
client.gcode("M112")
elif cmd == "q":
exit(0)
elif cmd == "n":
break
elif cmd == "?":
print("""\
s[tep] - run the next g-code line in the file
n[ext] - skip this line
e[stop] - issue an emergency stop
q[uit] - exit the debugger""")
else:
client.gcode(line)