components: correct imports

All imports must now be relative to work correctly with the
moonraker parent package.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-10-18 10:31:41 -04:00
parent b9a17e07e9
commit 0f8638fec7
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
38 changed files with 135 additions and 146 deletions

View File

@ -21,10 +21,10 @@ from typing import (
Union
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from http_client import HttpClient
from components.database import MoonrakerDatabase
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .http_client import HttpClient
from .database import MoonrakerDatabase
MOONLIGHT_URL = "https://arksine.github.io/moonlight"

View File

@ -34,8 +34,8 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest, WebsocketManager
from ..confighelper import ConfigHelper
from ..websockets import WebRequest, WebsocketManager
from tornado.httputil import HTTPServerRequest
from tornado.web import RequestHandler
from .database import MoonrakerDatabase as DBComp

View File

@ -6,7 +6,7 @@
from __future__ import annotations
import asyncio
import logging
from confighelper import SentinelClass
from ..confighelper import SentinelClass
from typing import (
TYPE_CHECKING,
@ -14,9 +14,9 @@ from typing import (
Dict
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
from .gpio import GpioFactory
from app import InternalTransport as ITransport
from ..app import InternalTransport as ITransport
SENTINEL = SentinelClass.get_instance()

View File

@ -20,10 +20,9 @@ from typing import (
Deque,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from . import klippy_apis
APIComp = klippy_apis.KlippyAPI
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .klippy_apis import KlippyAPI as APIComp
GCQueue = Deque[Dict[str, Any]]
TempStore = Dict[str, Dict[str, Deque[float]]]

View File

@ -15,7 +15,7 @@ from io import BytesIO
from functools import reduce
from threading import Lock as ThreadLock
import lmdb
from utils import SentinelClass, ServerError
from ..utils import SentinelClass, ServerError
# Annotation imports
from typing import (
@ -33,8 +33,8 @@ from typing import (
cast
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
DBRecord = Union[int, float, bool, str, List[Any], Dict[str, Any]]
DBType = Optional[DBRecord]
_T = TypeVar("_T")

View File

@ -20,7 +20,7 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
STAT_PATH = "/proc/self/stat"
DOC_URL = (

View File

@ -8,8 +8,8 @@ import asyncio
import pathlib
import logging
import json
from websockets import BaseSocketClient
from utils import get_unix_peer_credentials
from ..websockets import BaseSocketClient
from ..utils import get_unix_peer_credentials
# Annotation imports
from typing import (
@ -22,10 +22,10 @@ from typing import (
)
if TYPE_CHECKING:
from moonraker import Server
from confighelper import ConfigHelper
from websockets import WebRequest
from klippy_connection import KlippyConnection as Klippy
from ..server import Server
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from ..klippy_connection import KlippyConnection as Klippy
UNIX_BUFFER_LIMIT = 20 * 1024 * 1024

View File

@ -9,7 +9,7 @@ from . import file_manager as fm
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ...confighelper import ConfigHelper
def load_component(config: ConfigHelper) -> fm.FileManager:
return fm.load_component(config)

View File

@ -18,7 +18,7 @@ import time
from copy import deepcopy
from inotify_simple import INotify
from inotify_simple import flags as iFlags
from utils import MOONRAKER_PATH
from ...utils import MOONRAKER_PATH
# Annotation imports
from typing import (
@ -40,14 +40,14 @@ from typing import (
if TYPE_CHECKING:
from inotify_simple import Event as InotifyEvent
from confighelper import ConfigHelper
from websockets import WebRequest
from klippy_connection import KlippyConnection
from components import database
from components import klippy_apis
from components import shell_command
from components.job_queue import JobQueue
from components.job_state import JobState
from ...confighelper import ConfigHelper
from ...websockets import WebRequest
from ...klippy_connection import KlippyConnection
from .. import database
from .. import klippy_apis
from .. import shell_command
from ..job_queue import JobQueue
from ..job_state import JobState
StrOrPath = Union[str, pathlib.Path]
DBComp = database.MoonrakerDatabase
APIComp = klippy_apis.KlippyAPI

View File

@ -5,7 +5,7 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
from __future__ import annotations
import logging
from utils import load_system_module
from ..utils import load_system_module
# Annotation imports
from typing import (
@ -18,8 +18,8 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from eventloop import EventLoop
from ..confighelper import ConfigHelper
from ..eventloop import EventLoop
GPIO_CALLBACK = Callable[[float, float, int], Optional[Awaitable[None]]]
class GpioFactory:
@ -267,7 +267,7 @@ class GpioEvent(GpioBase):
self.error_count = 0
ret = self.callback(eventtime, evt_duration, self.value)
if ret is not None:
self.event_loop.create_task(ret)
self.event_loop.create_task(ret) # type: ignore
def _increment_error(self, eventtime: float) -> None:
if eventtime - self.last_error_reset > ERROR_RESET_TIME:

View File

@ -17,8 +17,8 @@ from typing import (
List,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .database import MoonrakerDatabase as DBComp
from .job_state import JobState
from .file_manager.file_manager import FileManager

View File

@ -12,7 +12,7 @@ import asyncio
import pathlib
import tempfile
import logging
from utils import ServerError
from ..utils import ServerError
from tornado.escape import url_escape, url_unescape
from tornado.httpclient import AsyncHTTPClient, HTTPRequest, HTTPError
from tornado.httputil import HTTPHeaders
@ -27,8 +27,8 @@ from typing import (
Any
)
if TYPE_CHECKING:
from server import Server
from confighelper import ConfigHelper
from ..server import Server
from ..confighelper import ConfigHelper
from io import BufferedWriter
StrOrPath = Union[str, pathlib.Path]

View File

@ -19,8 +19,8 @@ from typing import (
Union,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .klippy_apis import KlippyAPI
from .file_manager.file_manager import FileManager

View File

@ -16,7 +16,7 @@ from typing import (
List,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
from .klippy_apis import KlippyAPI
class JobState:

View File

@ -5,8 +5,8 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
from __future__ import annotations
from utils import SentinelClass
from websockets import WebRequest, Subscribable
from ..utils import SentinelClass
from ..websockets import WebRequest, Subscribable
# Annotation imports
from typing import (
@ -20,9 +20,9 @@ from typing import (
Mapping,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from klippy_connection import KlippyConnection as Klippy
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from ..klippy_connection import KlippyConnection as Klippy
Subscription = Dict[str, Optional[List[Any]]]
_T = TypeVar("_T")

View File

@ -18,7 +18,7 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
from ldap3.abstract.entry import Entry
class MoonrakerLDAP:

View File

@ -21,8 +21,8 @@ import distro
import tempfile
import getpass
import configparser
from confighelper import FileSourceWrapper
from utils import MOONRAKER_PATH
from ..confighelper import FileSourceWrapper
from ..utils import MOONRAKER_PATH
# Annotation imports
from typing import (
@ -39,10 +39,10 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from app import MoonrakerApp
from klippy_connection import KlippyConnection
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from ..app import MoonrakerApp
from ..klippy_connection import KlippyConnection
from .shell_command import ShellCommandFactory as SCMDComp
from .database import MoonrakerDatabase
from .file_manager.file_manager import FileManager

View File

@ -13,7 +13,7 @@ import pathlib
import ssl
from collections import deque
import paho.mqtt.client as paho_mqtt
from websockets import Subscribable, WebRequest, JsonRPC, APITransport
from ..websockets import Subscribable, WebRequest, JsonRPC, APITransport
# Annotation imports
from typing import (
@ -30,9 +30,9 @@ from typing import (
Deque,
)
if TYPE_CHECKING:
from app import APIDefinition
from confighelper import ConfigHelper
from klippy_connection import KlippyConnection as Klippy
from ..app import APIDefinition
from ..confighelper import ConfigHelper
from ..klippy_connection import KlippyConnection as Klippy
FlexCallback = Callable[[bytes], Optional[Coroutine]]
RPCCallback = Callable[..., Coroutine]

View File

@ -12,22 +12,16 @@ import logging
# Annotation imports
from typing import (
TYPE_CHECKING,
Type,
Optional,
Dict,
Any,
List,
Union,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .http_client import HttpClient
from . import klippy_apis
APIComp = klippy_apis.KlippyAPI
from .klippy_apis import KlippyAPI as APIComp
class Notifier:
def __init__(self, config: ConfigHelper) -> None:

View File

@ -15,8 +15,8 @@ from typing import (
List,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .klippy_apis import KlippyAPI as APIComp
from .file_manager.file_manager import FileManager
from .job_queue import JobQueue

View File

@ -13,7 +13,7 @@ import errno
import logging
import asyncio
from collections import deque
from utils import ServerError
from ..utils import ServerError
# Annotation imports
from typing import (
@ -28,11 +28,9 @@ from typing import (
Coroutine,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from . import klippy_apis
from .file_manager import file_manager
APIComp = klippy_apis.KlippyAPI
FMComp = file_manager.FileManager
from ..confighelper import ConfigHelper
from .klippy_apis import KlippyAPI as APIComp
from .file_manager.file_manager import FileManager as FMComp
FlexCallback = Callable[..., Optional[Coroutine]]
MIN_EST_TIME = 10.

View File

@ -27,15 +27,14 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .machine import Machine
from . import klippy_apis
from .klippy_apis import KlippyAPI as APIComp
from .mqtt import MQTTClient
from .template import JinjaTemplate
from .http_client import HttpClient
from klippy_connection import KlippyConnection
APIComp = klippy_apis.KlippyAPI
class PrinterPower:
def __init__(self, config: ConfigHelper) -> None:

View File

@ -26,8 +26,8 @@ from typing import (
Dict,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest, WebsocketManager
from ..confighelper import ConfigHelper
from ..websockets import WebRequest, WebsocketManager
from . import shell_command
STAT_CALLBACK = Callable[[int], Optional[Awaitable]]

View File

@ -15,7 +15,7 @@ from typing import (
Any
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
from .file_manager.file_manager import FileManager
class Secrets:

View File

@ -27,8 +27,9 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .mqtt import MQTTClient
SENSOR_UPDATE_TIME = 1.0
SENSOR_EVENT_NAME = "sensors:sensor_update"
@ -42,12 +43,6 @@ class SensorConfiguration:
source: str = ""
if TYPE_CHECKING:
from confighelper import ConfigHelper
from .mqtt import MQTTClient
def _set_result(
name: str, value: Union[int, float], store: Dict[str, Union[int, float]]
) -> None:

View File

@ -10,7 +10,7 @@ import shlex
import logging
import signal
import asyncio
from utils import ServerError
from ..utils import ServerError
# Annotation imports
from typing import (
@ -24,7 +24,7 @@ from typing import (
Set,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
OutputCallback = Optional[Callable[[bytes], None]]
class ShellCommandError(ServerError):

View File

@ -14,7 +14,7 @@ import pathlib
import base64
import tornado.websocket
from tornado.escape import url_escape
from websockets import Subscribable, WebRequest
from ..websockets import Subscribable, WebRequest
import logging.handlers
import tempfile
@ -31,20 +31,20 @@ from typing import (
Any,
)
if TYPE_CHECKING:
from app import InternalTransport
from confighelper import ConfigHelper
from websockets import WebsocketManager, BaseSocketClient
from ..app import InternalTransport
from ..confighelper import ConfigHelper
from ..websockets import WebsocketManager, BaseSocketClient
from tornado.websocket import WebSocketClientConnection
from components.database import MoonrakerDatabase
from components.klippy_apis import KlippyAPI
from components.job_state import JobState
from components.machine import Machine
from components.file_manager.file_manager import FileManager
from components.http_client import HttpClient
from components.power import PrinterPower
from components.announcements import Announcements
from components.webcam import WebcamManager, WebCam
from klippy_connection import KlippyConnection
from .database import MoonrakerDatabase
from .klippy_apis import KlippyAPI
from .job_state import JobState
from .machine import Machine
from .file_manager.file_manager import FileManager
from .http_client import HttpClient
from .power import PrinterPower
from .announcements import Announcements
from .webcam import WebcamManager, WebCam
from ..klippy_connection import KlippyConnection
COMPONENT_VERSION = "0.0.1"
SP_VERSION = "0.1"

View File

@ -17,8 +17,8 @@ from typing import (
)
if TYPE_CHECKING:
from server import Server
from confighelper import ConfigHelper
from ..server import Server
from ..confighelper import ConfigHelper
from .secrets import Secrets
class TemplateFactory:

View File

@ -9,7 +9,7 @@ from . import update_manager as um
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ...confighelper import ConfigHelper
def load_component(config: ConfigHelper) -> um.UpdateManager:
return um.load_component(config)

View File

@ -24,7 +24,7 @@ from typing import (
Tuple
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ...confighelper import ConfigHelper
from .update_manager import CommandHelper
from ..machine import Machine
from ..file_manager.file_manager import FileManager

View File

@ -8,15 +8,15 @@ from __future__ import annotations
import os
import sys
import copy
from utils import MOONRAKER_PATH
from ...utils import MOONRAKER_PATH
from typing import (
TYPE_CHECKING,
Dict
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from components.database import MoonrakerDatabase
from ...confighelper import ConfigHelper
from ..database import MoonrakerDatabase
KLIPPER_DEFAULT_PATH = os.path.expanduser("~/klipper")
KLIPPER_DEFAULT_EXEC = os.path.expanduser("~/klippy-env/bin/python")

View File

@ -10,8 +10,8 @@ import time
from typing import TYPE_CHECKING, Dict, Any, Optional
if TYPE_CHECKING:
from confighelper import ConfigHelper
from utils import ServerError
from ...confighelper import ConfigHelper
from ...utils import ServerError
from .update_manager import CommandHelper
class BaseDeploy:

View File

@ -23,8 +23,8 @@ from typing import (
List,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from components import shell_command
from ...confighelper import ConfigHelper
from ...components import shell_command
from .update_manager import CommandHelper
from ..http_client import HttpClient

View File

@ -14,7 +14,7 @@ import zipfile
import time
import tempfile
import re
from thirdparty.packagekit import enums as PkEnum
from ...thirdparty.packagekit import enums as PkEnum
from . import base_config
from .base_deploy import BaseDeploy
from .app_deploy import AppDeploy
@ -37,18 +37,18 @@ from typing import (
cast
)
if TYPE_CHECKING:
from server import Server
from confighelper import ConfigHelper
from websockets import WebRequest
from klippy_connection import KlippyConnection
from components.shell_command import ShellCommandFactory as SCMDComp
from components.database import MoonrakerDatabase as DBComp
from components.database import NamespaceWrapper
from components.dbus_manager import DbusManager
from components.machine import Machine
from components.http_client import HttpClient
from components.file_manager.file_manager import FileManager
from eventloop import FlexTimer
from ...server import Server
from ...confighelper import ConfigHelper
from ...websockets import WebRequest
from ...klippy_connection import KlippyConnection
from ..shell_command import ShellCommandFactory as SCMDComp
from ..database import MoonrakerDatabase as DBComp
from ..database import NamespaceWrapper
from ..dbus_manager import DbusManager
from ..machine import Machine
from ..http_client import HttpClient
from ..file_manager.file_manager import FileManager
from ...eventloop import FlexTimer
from dbus_next import Variant
from dbus_next.aio import ProxyInterface
JsonType = Union[List[Any], Dict[str, Any]]

View File

@ -13,7 +13,7 @@ import re
import time
import zipfile
from .app_deploy import AppDeploy
from utils import verify_source
from ...utils import verify_source
# Annotation imports
from typing import (
@ -25,7 +25,7 @@ from typing import (
List,
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ...confighelper import ConfigHelper
from .update_manager import CommandHelper
RINFO_KEYS = [

View File

@ -20,9 +20,9 @@ from typing import (
)
if TYPE_CHECKING:
from server import Server
from confighelper import ConfigHelper
from websockets import WebRequest
from ..server import Server
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
from .database import MoonrakerDatabase
from .machine import Machine
from .shell_command import ShellCommandFactory

View File

@ -28,10 +28,8 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from websockets import WebRequest
from . import klippy_apis
APIComp = klippy_apis.KlippyAPI
from ..confighelper import ConfigHelper
from ..websockets import WebRequest
class OnOff(str, Enum):
on: str = "on"
@ -447,9 +445,15 @@ class WLED:
# Full control of wled
# state: True, False, "on", "off"
# preset: wled preset (int) to use (ignored if state False or "Off")
async def set_wled_state(self: WLED, strip: str, state: str = None,
preset: int = -1, brightness: int = -1,
intensity: int = -1, speed: int = -1) -> None:
async def set_wled_state(
self: WLED,
strip: str,
state: Optional[str] = None,
preset: int = -1,
brightness: int = -1,
intensity: int = -1,
speed: int = -1
) -> None:
status = None
if isinstance(state, bool):

View File

@ -14,7 +14,7 @@ from zeroconf.asyncio import AsyncServiceInfo, AsyncZeroconf
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional
if TYPE_CHECKING:
from confighelper import ConfigHelper
from ..confighelper import ConfigHelper
from .machine import Machine