Update gdbus.py

This commit is contained in:
Pascal Vizeli 2018-04-24 15:52:18 +02:00 committed by GitHub
parent 7363951a9a
commit 2a81ced817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""