From ceaa3c3ad5c7b4b7ebe1bc5ca8ae1c1a30ecb006 Mon Sep 17 00:00:00 2001 From: Matthias Bach Date: Sun, 15 Dec 2019 20:47:40 +0100 Subject: [PATCH] Reorder the initialisation of the ratbagd client When the API version mismatches we want to fail early before performing any more complex initialisation. We do however have to check for devices first so that we can distinguish cases where we cannot access the daemon from those where it is too old to provide an API version. --- tools/ratbagd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/ratbagd.py b/tools/ratbagd.py index dcae8024..5ddec361 100644 --- a/tools/ratbagd.py +++ b/tools/ratbagd.py @@ -250,13 +250,13 @@ class Ratbagd(_RatbagdDBus): def __init__(self, api_version): super().__init__("Manager", None) - result = self._get_dbus_property("Devices") or [] - self._devices = [RatbagdDevice(objpath) for objpath in result] - self._proxy.connect("notify::g-name-owner", self._on_name_owner_changed) - if self.api_version == None and not self._proxy.get_cached_property_names(): + result = self._get_dbus_property("Devices") + if result is None and not self._proxy.get_cached_property_names(): raise RatbagdUnavailable("Make sure it is running and your user is in the required groups.") if self.api_version != api_version: raise RatbagdIncompatible(self.api_version or -1, api_version) + self._devices = [RatbagdDevice(objpath) for objpath in result or []] + self._proxy.connect("notify::g-name-owner", self._on_name_owner_changed) def _on_name_owner_changed(self, *kwargs): self.emit("daemon-disappeared")