file_manager: improve gcode path warning

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-10-18 05:32:34 -04:00
parent 6b3c78da71
commit a8cbfe6345
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 7 additions and 9 deletions

View File

@ -164,18 +164,16 @@ class FileManager:
def validate_gcode_path(self, gc_path: str) -> None: def validate_gcode_path(self, gc_path: str) -> None:
gc_dir = pathlib.Path(gc_path).expanduser() gc_dir = pathlib.Path(gc_path).expanduser()
if not gc_dir.exists():
self.server.add_warning(
f"GCode path received from Klipper does not exist: {gc_dir}",
warn_id="gcode_path"
)
return
if "gcodes" in self.file_paths: if "gcodes" in self.file_paths:
expected = self.file_paths["gcodes"] expected = self.file_paths["gcodes"]
if not gc_dir.samefile(self.file_paths["gcodes"]): if not gc_dir.exists() or not gc_dir.samefile(expected):
self.server.add_warning( self.server.add_warning(
"GCode path received from Klipper does not match " "GCode path received from Klipper does not match expected "
f"expected path: {expected}", "location.\n\n"
f"Received: '{gc_dir}'\nExpected: '{expected}'\n\n"
"Modify the [virtual_sdcard] section Klipper's "
"configuration to correct this error.\n\n"
f"[virtual_sdcard]\npath: {expected}",
warn_id="gcode_path" warn_id="gcode_path"
) )
else: else: