diff --git a/projects/octostep/BUILD b/projects/octostep/BUILD new file mode 100644 index 0000000..58bbbc4 --- /dev/null +++ b/projects/octostep/BUILD @@ -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"), + ], +) diff --git a/projects/octostep/__main__.py b/projects/octostep/__main__.py new file mode 100644 index 0000000..726f982 --- /dev/null +++ b/projects/octostep/__main__.py @@ -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)