klippy_connection: update configuration
Use the ConfigHelper's getpath() method to configure the unix socket. The option may now be a template where the datapath is passed into the context. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
b291d94596
commit
36536535bc
|
@ -11,7 +11,6 @@ import time
|
|||
import logging
|
||||
import json
|
||||
import getpass
|
||||
import confighelper
|
||||
import asyncio
|
||||
import socket
|
||||
import struct
|
||||
|
@ -31,8 +30,10 @@ from typing import (
|
|||
Set,
|
||||
)
|
||||
if TYPE_CHECKING:
|
||||
from moonraker import Server
|
||||
from app import MoonrakerApp
|
||||
from websockets import WebRequest, Subscribable
|
||||
from confighelper import ConfigHelper
|
||||
from components.klippy_apis import KlippyAPI
|
||||
from components.file_manager.file_manager import FileManager
|
||||
from components.machine import Machine
|
||||
|
@ -45,11 +46,9 @@ MAX_LOG_ATTEMPTS = 10 * LOG_ATTEMPT_INTERVAL
|
|||
UNIX_BUFFER_LIMIT = 20 * 1024 * 1024
|
||||
|
||||
class KlippyConnection:
|
||||
def __init__(self, config: confighelper.ConfigHelper) -> None:
|
||||
self.server = config.get_server()
|
||||
uds_addr: str = config.get(
|
||||
'klippy_uds_address', "/tmp/klippy_uds")
|
||||
self.uds_address = pathlib.Path(uds_addr).expanduser().resolve()
|
||||
def __init__(self, server: Server) -> None:
|
||||
self.server = server
|
||||
self.uds_address = pathlib.Path("/tmp/klippy_uds")
|
||||
self.writer: Optional[asyncio.StreamWriter] = None
|
||||
self.connection_mutex: asyncio.Lock = asyncio.Lock()
|
||||
self.event_loop = self.server.get_event_loop()
|
||||
|
@ -81,6 +80,11 @@ class KlippyConnection:
|
|||
need_klippy_reg=False)
|
||||
self.server.register_component("klippy_connection", self)
|
||||
|
||||
def configure(self, config: ConfigHelper):
|
||||
self.uds_address = config.getpath(
|
||||
"klippy_uds_address", self.uds_address
|
||||
)
|
||||
|
||||
@property
|
||||
def klippy_apis(self) -> KlippyAPI:
|
||||
return self.server.lookup_component("klippy_apis")
|
||||
|
|
|
@ -82,8 +82,7 @@ class Server:
|
|||
log_level = logging.DEBUG if args["verbose"] else logging.INFO
|
||||
logging.getLogger().setLevel(log_level)
|
||||
self.event_loop.set_debug(args["asyncio_debug"])
|
||||
|
||||
self.klippy_connection = KlippyConnection(config)
|
||||
self.klippy_connection = KlippyConnection(self)
|
||||
|
||||
# Tornado Application/Server
|
||||
self.moonraker_app = app = MoonrakerApp(config)
|
||||
|
@ -232,6 +231,7 @@ class Server:
|
|||
for section in cfg_sections:
|
||||
self.load_component(config, section, None)
|
||||
|
||||
self.klippy_connection.configure(config)
|
||||
config.validate_config()
|
||||
|
||||
def load_component(self,
|
||||
|
|
Loading…
Reference in New Issue