mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 17:56:33 +00:00
Update gdbus.py
This commit is contained in:
parent
7363951a9a
commit
2a81ced817
@ -1,6 +1,7 @@
|
|||||||
"""DBus implementation with glib."""
|
"""DBus implementation with glib."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
import shlex
|
import shlex
|
||||||
import re
|
import re
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
@ -67,7 +68,14 @@ class DBus:
|
|||||||
def _gvariant(raw):
|
def _gvariant(raw):
|
||||||
"""Parse GVariant input to python."""
|
"""Parse GVariant input to python."""
|
||||||
raw = RE_GVARIANT_TULPE.sub(r"[\1]", raw)
|
raw = RE_GVARIANT_TULPE.sub(r"[\1]", raw)
|
||||||
return raw
|
raw = RE_GVARIANT_VARIANT.sub(r"\1", raw)
|
||||||
|
raw = RE_GVARIANT_STRING.sub(r"\"\1\"", raw)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return json.loads(raw)
|
||||||
|
except json.JSONDecodeError as err:
|
||||||
|
_LOGGER.error("Can't parse '%s': %s", raw, err)
|
||||||
|
raise DBusParseError() from None
|
||||||
|
|
||||||
async def call_dbus(self, interface, method, *args):
|
async def call_dbus(self, interface, method, *args):
|
||||||
"""Call a dbus method."""
|
"""Call a dbus method."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user