From 8cbb4b510b57624e56a60c4055eb3d38aeca8801 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Fri, 30 Oct 2020 10:37:34 +0100 Subject: [PATCH] Init template sooner (#2194) --- supervisor/plugins/audio.py | 12 ++++++------ supervisor/plugins/dns.py | 21 ++++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/supervisor/plugins/audio.py b/supervisor/plugins/audio.py index a8163c5ff..1aaa7365b 100644 --- a/supervisor/plugins/audio.py +++ b/supervisor/plugins/audio.py @@ -91,6 +91,12 @@ class Audio(JsonConfig, CoreSysAttributes): async def load(self) -> None: """Load Audio setup.""" + # Initialize Client Template + try: + self.client_template = jinja2.Template(PULSE_CLIENT_TMPL.read_text()) + except OSError as err: + _LOGGER.error("Can't read pulse-client.tmpl: %s", err) + # Check Audio state try: # Evaluate Version if we lost this information @@ -114,12 +120,6 @@ class Audio(JsonConfig, CoreSysAttributes): if not await self.instance.is_running(): await self.start() - # Initialize Client Template - try: - self.client_template = jinja2.Template(PULSE_CLIENT_TMPL.read_text()) - except OSError as err: - _LOGGER.error("Can't read pulse-client.tmpl: %s", err) - # Setup default asound config asound = self.sys_config.path_audio.joinpath("asound") if not asound.exists(): diff --git a/supervisor/plugins/dns.py b/supervisor/plugins/dns.py index eae23896e..7f04db300 100644 --- a/supervisor/plugins/dns.py +++ b/supervisor/plugins/dns.py @@ -131,9 +131,18 @@ class CoreDNS(JsonConfig, CoreSysAttributes): async def load(self) -> None: """Load DNS setup.""" - self._init_hosts() + # Initialize CoreDNS Template + try: + self.resolv_template = jinja2.Template(RESOLV_TMPL.read_text()) + except OSError as err: + _LOGGER.error("Can't read resolve.tmpl: %s", err) + try: + self.hosts_template = jinja2.Template(HOSTS_TMPL.read_text()) + except OSError as err: + _LOGGER.error("Can't read hosts.tmpl: %s", err) # Check CoreDNS state + self._init_hosts() try: # Evaluate Version if we lost this information if not self.version: @@ -153,16 +162,6 @@ class CoreDNS(JsonConfig, CoreSysAttributes): self.image = self.instance.image self.save_data() - # Initialize CoreDNS Template - try: - self.resolv_template = jinja2.Template(RESOLV_TMPL.read_text()) - except OSError as err: - _LOGGER.error("Can't read resolve.tmpl: %s", err) - try: - self.hosts_template = jinja2.Template(HOSTS_TMPL.read_text()) - except OSError as err: - _LOGGER.error("Can't read hosts.tmpl: %s", err) - # Run CoreDNS with suppress(CoreDNSError): if not await self.instance.is_running():