mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-27 11:06:32 +00:00
Update gdbus.py
This commit is contained in:
parent
5a6051f9a1
commit
34d67a7bcd
@ -10,7 +10,7 @@ CALL = ("gdbus call --system --dest {bus} --object-path {obj} "
|
||||
"--method {obj}.{method} {args}")
|
||||
|
||||
|
||||
class DbusCallError(Exception):
|
||||
class DbusError(Exception):
|
||||
"""Dbus call going wrong."""
|
||||
pass
|
||||
|
||||
@ -23,6 +23,11 @@ class Dbus(object):
|
||||
self.loop = loop
|
||||
self.bus_name = bus_name
|
||||
self.object_path = object_path
|
||||
|
||||
@staticmethod
|
||||
def _gvariant(raw):
|
||||
"""Parse GVariant input to python."""
|
||||
return raw
|
||||
|
||||
async def _call_dbus(self, method, *args):
|
||||
"""Call a dbus method."""
|
||||
@ -46,12 +51,12 @@ class Dbus(object):
|
||||
data, _ = await proc.communicate()
|
||||
except OSError as err:
|
||||
_LOGGER.error("Can't send dbus command %s: %s", method, err)
|
||||
raise DbusCallError() from None
|
||||
raise DbusError() from None
|
||||
|
||||
# Success?
|
||||
if proc.returncode != 0:
|
||||
_LOGGER.info("Error %s.%s: %s", self.object_path, method, data)
|
||||
raise DbusCallError()
|
||||
raise DbusError()
|
||||
|
||||
# Parse and return data
|
||||
return self._gvariant(data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user