file_manager: update paths in "ready" event handler
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
df81854f89
commit
706d86dd21
|
@ -287,13 +287,7 @@ class Server:
|
||||||
return
|
return
|
||||||
if send_id:
|
if send_id:
|
||||||
self.init_list.append("identified")
|
self.init_list.append("identified")
|
||||||
self.klippy_info = result
|
self.klippy_info = dict(result)
|
||||||
# Update filemanager fixed paths
|
|
||||||
fixed_paths = {k: result[k] for k in
|
|
||||||
['klipper_path', 'python_path',
|
|
||||||
'log_file', 'config_file']}
|
|
||||||
file_manager = self.lookup_plugin('file_manager')
|
|
||||||
file_manager.update_fixed_paths(fixed_paths)
|
|
||||||
self.klippy_state = result.get('state', "unknown")
|
self.klippy_state = result.get('state', "unknown")
|
||||||
if self.klippy_state == "ready":
|
if self.klippy_state == "ready":
|
||||||
await self._verify_klippy_requirements()
|
await self._verify_klippy_requirements()
|
||||||
|
|
|
@ -44,6 +44,9 @@ class FileManager:
|
||||||
self.server.register_upload_handler("/server/files/upload")
|
self.server.register_upload_handler("/server/files/upload")
|
||||||
self.server.register_upload_handler("/api/files/local")
|
self.server.register_upload_handler("/api/files/local")
|
||||||
|
|
||||||
|
self.server.register_event_handler(
|
||||||
|
"server:klippy_ready", self._update_fixed_paths)
|
||||||
|
|
||||||
# Register Klippy Configuration Path
|
# Register Klippy Configuration Path
|
||||||
config_path = config.get('config_path', None)
|
config_path = config.get('config_path', None)
|
||||||
if config_path is not None:
|
if config_path is not None:
|
||||||
|
@ -52,11 +55,15 @@ class FileManager:
|
||||||
raise config.error(
|
raise config.error(
|
||||||
"Option 'config_path' is not a valid directory")
|
"Option 'config_path' is not a valid directory")
|
||||||
|
|
||||||
def update_fixed_paths(self, paths):
|
def _update_fixed_paths(self):
|
||||||
|
kinfo = self.server.get_klippy_info()
|
||||||
|
paths = {k: kinfo.get(k) for k in
|
||||||
|
['klipper_path', 'python_path',
|
||||||
|
'log_file', 'config_file']}
|
||||||
if paths == self.fixed_path_args:
|
if paths == self.fixed_path_args:
|
||||||
# No change in fixed paths
|
# No change in fixed paths
|
||||||
return
|
return
|
||||||
self.fixed_path_args = dict(paths)
|
self.fixed_path_args = paths
|
||||||
str_paths = "\n".join([f"{k}: {v}" for k, v in paths.items()])
|
str_paths = "\n".join([f"{k}: {v}" for k, v in paths.items()])
|
||||||
logging.debug(f"\nUpdating Fixed Paths:\n{str_paths}")
|
logging.debug(f"\nUpdating Fixed Paths:\n{str_paths}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue