paneldue: Improve file name parsing

Previously file names containing whitespace were not parsed correctly.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-01-01 12:41:02 -05:00
parent 4aa2a86e3b
commit a535e6e94a
1 changed files with 10 additions and 2 deletions

View File

@ -362,12 +362,18 @@ class PanelDue:
# require special handling # require special handling
parts = script.split() parts = script.split()
cmd = parts[0].strip() cmd = parts[0].strip()
if cmd in ["M23", "M30", "M32", "M36", "M37", "M98"]:
arg = script[len(cmd):].strip()
parts = [cmd, arg]
# Check for commands that query state and require immediate response # Check for commands that query state and require immediate response
if cmd in self.direct_gcodes: if cmd in self.direct_gcodes:
params = {} params = {}
for p in parts[1:]: for p in parts[1:]:
arg = p[0].lower() if p[0].lower() in "psr" else "p" if p[0] not in "PSR":
params["arg_p"] = p.strip(" \"\t\n")
continue
arg = p[0].lower()
try: try:
val = int(p[1:].strip()) if arg in "sr" \ val = int(p[1:].strip()) if arg in "sr" \
else p[1:].strip(" \"\t\n") else p[1:].strip(" \"\t\n")
@ -376,7 +382,7 @@ class PanelDue:
self.handle_gcode_response("!! " + msg) self.handle_gcode_response("!! " + msg)
logging.exception(msg) logging.exception(msg)
return return
params["arg_" + arg] = val params[f"arg_{arg}"] = val
func = self.direct_gcodes[cmd] func = self.direct_gcodes[cmd]
self.queue_command(func, **params) self.queue_command(func, **params)
return return
@ -743,6 +749,8 @@ class PanelDue:
# "gcodes/" root. The M20 HACK should add this in some cases. # "gcodes/" root. The M20 HACK should add this in some cases.
# Ideally we would add support to the PanelDue firmware that # Ideally we would add support to the PanelDue firmware that
# indicates Moonraker supports a "gcodes" directory. # indicates Moonraker supports a "gcodes" directory.
if filename[0] == "/":
filename = filename[1:]
if not filename.startswith("gcodes/"): if not filename.startswith("gcodes/"):
filename = "gcodes/" + filename filename = "gcodes/" + filename