Initialize correctly _dbus_error_name in BusErr classes

To be consistent with dbus.DbusException classes which do the
following in __init__:

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        if name is not None or getattr(self, '_dbus_error_name', None) is None:
            self._dbus_error_name = name
        if kwargs:
            raise TypeError('DBusException does not take keyword arguments: %s'
                            % ', '.join(kwargs.keys()))
        Exception.__init__(self, *args)

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
This commit is contained in:
Frederic Martinsons
2020-10-27 14:39:30 +01:00
committed by Thomas Haller
parent 7bc01ea14c
commit f225148754

View File

@@ -406,46 +406,74 @@ IFACE_DHCP6_CONFIG = "org.freedesktop.NetworkManager.DHCP6Config"
class BusErr:
class UnknownInterfaceException(dbus.DBusException):
_dbus_error_name = IFACE_DBUS + ".UnknownInterface"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.UnknownInterface".format(IFACE_DBUS)
dbus.DBusException.__init__(self, *args, **kwargs)
class UnknownPropertyException(dbus.DBusException):
_dbus_error_name = IFACE_DBUS + ".UnknownProperty"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.UnknownProperty".format(IFACE_DBUS)
dbus.DBusException.__init__(self, *args, **kwargs)
class InvalidPropertyException(dbus.DBusException):
_dbus_error_name = IFACE_CONNECTION + ".InvalidProperty"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.InvalidProperty".format(IFACE_CONNECTION)
dbus.DBusException.__init__(self, *args, **kwargs)
class MissingPropertyException(dbus.DBusException):
_dbus_error_name = IFACE_CONNECTION + ".MissingProperty"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.MissingProperty".format(IFACE_CONNECTION)
dbus.DBusException.__init__(self, *args, **kwargs)
class InvalidSettingException(dbus.DBusException):
_dbus_error_name = IFACE_CONNECTION + ".InvalidSetting"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.InvalidSetting".format(IFACE_CONNECTION)
dbus.DBusException.__init__(self, *args, **kwargs)
class MissingSettingException(dbus.DBusException):
_dbus_error_name = IFACE_CONNECTION + ".MissingSetting"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.MissingSetting".format(IFACE_CONNECTION)
dbus.DBusException.__init__(self, *args, **kwargs)
class NotSoftwareException(dbus.DBusException):
_dbus_error_name = IFACE_DEVICE + ".NotSoftware"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.NotSoftware".format(IFACE_DEVICE)
dbus.DBusException.__init__(self, *args, **kwargs)
class ApNotFoundException(dbus.DBusException):
_dbus_error_name = IFACE_WIFI + ".AccessPointNotFound"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.AccessPointNotFound".format(IFACE_WIFI)
dbus.DBusException.__init__(self, *args, **kwargs)
class PermissionDeniedException(dbus.DBusException):
_dbus_error_name = IFACE_NM + ".PermissionDenied"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.PermissionDenied".format(IFACE_NM)
dbus.DBusException.__init__(self, *args, **kwargs)
class UnknownDeviceException(dbus.DBusException):
_dbus_error_name = IFACE_NM + ".UnknownDevice"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.UnknownDevice".format(IFACE_NM)
dbus.DBusException.__init__(self, *args, **kwargs)
class UnknownConnectionException(dbus.DBusException):
_dbus_error_name = IFACE_NM + ".UnknownConnection"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.UnknownConnection".format(IFACE_NM)
dbus.DBusException.__init__(self, *args, **kwargs)
class InvalidHostnameException(dbus.DBusException):
_dbus_error_name = IFACE_SETTINGS + ".InvalidHostname"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.InvalidHostname".format(IFACE_SETTINGS)
dbus.DBusException.__init__(self, *args, **kwargs)
class NoSecretsException(dbus.DBusException):
_dbus_error_name = IFACE_AGENT_MANAGER + ".NoSecrets"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.NoSecrets".format(IFACE_AGENT_MANAGER)
dbus.DBusException.__init__(self, *args, **kwargs)
class UserCanceledException(dbus.DBusException):
_dbus_error_name = IFACE_AGENT_MANAGER + ".UserCanceled"
def __init__(self, *args, **kwargs):
self._dbus_error_name = "{}.UserCanceled".format(IFACE_AGENT_MANAGER)
dbus.DBusException.__init__(self, *args, **kwargs)
@staticmethod
def from_nmerror(e):