Files
supervisor/hassio/dbus/utils.py
Fabian Affolter c2299ef8da Fix typos (#704)
2018-09-18 18:17:20 +02:00

15 lines
394 B
Python

"""Utils for D-Bus."""
from ..exceptions import DBusNotConnectedError
def dbus_connected(method):
"""Wrapper for check if D-Bus is connected."""
def wrap_dbus(api, *args, **kwargs):
"""Check if D-Bus is connected before call a method."""
if api.dbus is None:
raise DBusNotConnectedError()
return method(api, *args, **kwargs)
return wrap_dbus