Update requirements; new homeassistant dep. Also don't import kazoo
authorScott Gasch <[email protected]>
Wed, 24 Aug 2022 01:27:09 +0000 (18:27 -0700)
committerScott Gasch <[email protected]>
Wed, 24 Aug 2022 01:27:09 +0000 (18:27 -0700)
unless we try to load args from zookeeper.

config.py
requirements.txt

index 1a362a381eeaac36b6b8fabafa2db548ee82b1f0..a98db575661621e3e7baf5c285cb71337f9d0d52 100644 (file)
--- a/config.py
+++ b/config.py
@@ -90,9 +90,6 @@ import re
 import sys
 from typing import Any, Dict, List, Optional, Tuple
 
-from kazoo.client import KazooClient
-from kazoo.protocol.states import WatchedEvent
-
 import scott_secrets
 
 # This module is commonly used by others in here and should avoid
@@ -225,7 +222,7 @@ class Config:
         # A zookeeper client that is lazily created so as to not incur
         # the latency of connecting to zookeeper for programs that are
         # not reading or writing their config data into zookeeper.
-        self.zk: Optional[KazooClient] = None
+        self.zk: Optional[Any] = None
 
         # Per known zk file, what is the max version we have seen?
         self.max_version: Dict[str, int] = {}
@@ -378,7 +375,7 @@ class Config:
                                     sys.argv.append(value)
                     arg = ''
 
-    def _process_dynamic_args(self, event: WatchedEvent):
+    def _process_dynamic_args(self, event):
         assert self.zk
         logger = logging.getLogger(__name__)
         contents, meta = self.zk.get(event.path, watch=self._process_dynamic_args)
@@ -422,6 +419,8 @@ class Config:
         if loadfile is not None:
             zkpath = None
             if loadfile[:3] == 'zk:':
+                from kazoo.client import KazooClient
+
                 try:
                     if self.zk is None:
                         self.zk = KazooClient(
@@ -544,6 +543,8 @@ class Config:
                     zkpath = re.sub(r'//+', '/', zkpath)
                 try:
                     if not self.zk:
+                        from kazoo.client import KazooClient
+
                         self.zk = KazooClient(
                             hosts=scott_secrets.ZOOKEEPER_NODES,
                             use_ssl=True,
index a8673e996c044fc3d76212d7b42307456c7e58de..6016dd999547354ef81d3de97604b94aca6b0e00 100644 (file)
@@ -25,3 +25,4 @@ SpeechRecognition
 sphinx
 sqlalchemy
 tinytuya
+homeassistant-api