diff options
| -rw-r--r-- | config.py | 11 | ||||
| -rw-r--r-- | requirements.txt | 1 |
2 files changed, 7 insertions, 5 deletions
@@ -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, diff --git a/requirements.txt b/requirements.txt index a8673e9..6016dd9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,3 +25,4 @@ SpeechRecognition sphinx sqlalchemy tinytuya +homeassistant-api |
