file_manager: add option to opt out of klipper check

Some installations do not have Klipper's configuration
in the data path's "config" folder.  Provide a way to
opt out of this check.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-12-16 15:25:38 -05:00
parent 6d8cb762ff
commit 3b53d9532d
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B

@ -104,6 +104,7 @@ class FileManager:
self.scheduled_notifications: Dict[str, asyncio.TimerHandle] = {} self.scheduled_notifications: Dict[str, asyncio.TimerHandle] = {}
self.fixed_path_args: Dict[str, Any] = {} self.fixed_path_args: Dict[str, Any] = {}
self.queue_gcodes: bool = config.getboolean('queue_gcode_uploads', False) self.queue_gcodes: bool = config.getboolean('queue_gcode_uploads', False)
self.check_klipper_path = config.getboolean("check_klipper_config_path", True)
# Register file management endpoints # Register file management endpoints
self.server.register_endpoint( self.server.register_endpoint(
@ -195,24 +196,25 @@ class FileManager:
"klippy.log", log_path, force=True) "klippy.log", log_path, force=True)
# Validate config file # Validate config file
cfg_file: Optional[str] = paths.get("config_file") if self.check_klipper_path:
cfg_parent = self.file_paths.get("config") cfg_file: Optional[str] = paths.get("config_file")
if cfg_file is not None and cfg_parent is not None: cfg_parent = self.file_paths.get("config")
cfg_path = pathlib.Path(cfg_file).expanduser() if cfg_file is not None and cfg_parent is not None:
par_path = pathlib.Path(cfg_parent) cfg_path = pathlib.Path(cfg_file).expanduser()
if ( par_path = pathlib.Path(cfg_parent)
par_path in cfg_path.parents or if (
par_path.resolve() in cfg_path.resolve().parents par_path in cfg_path.parents or
): par_path.resolve() in cfg_path.resolve().parents
self.server.remove_warning("klipper_config") ):
else: self.server.remove_warning("klipper_config")
self.server.add_warning( else:
"file_manager: Klipper configuration file not located in " self.server.add_warning(
"'config' folder.\n\n" "file_manager: Klipper configuration file not located in "
f"Klipper Config Path: {cfg_path}\n\n" "'config' folder.\n\n"
f"Config Folder: {par_path}", f"Klipper Config Path: {cfg_path}\n\n"
warn_id="klipper_config" f"Config Folder: {par_path}",
) warn_id="klipper_config"
)
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()