forked from drath/libratbag
tools: change the exception to just RatbagdUnavailable
ratbag-command has an 'except RatbagdDBusUnavailable' line despite that class never being defined. That's ok because we'll never throw it in this case but it's still confusing (to flake8). So let's change the class name to something more generic and define it in ratbagc.py Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -80,6 +80,11 @@ class RatbagErrorCode(metaclass=MetaRatbag):
|
||||
RATBAG_ERROR_IMPLEMENTATION = libratbag.RATBAG_ERROR_IMPLEMENTATION
|
||||
|
||||
|
||||
class RatbagdUnavailable(Exception):
|
||||
"""Signals DBus is unavailable or the ratbagd daemon is not available."""
|
||||
pass
|
||||
|
||||
|
||||
class RatbagError(Exception):
|
||||
"""A common base exception to catch any ratbag exception."""
|
||||
pass
|
||||
|
||||
@@ -28,7 +28,7 @@ import sys
|
||||
import argparse
|
||||
import re
|
||||
|
||||
from ratbagd import Ratbagd, RatbagdDevice, RatbagdProfile, RatbagdMacro, RatbagdResolution, RatbagdButton, RatbagdLed, RatbagdDBusUnavailable, RatbagError, RatbagErrorCode, RatbagErrorCapability # NOQA
|
||||
from ratbagd import Ratbagd, RatbagdDevice, RatbagdProfile, RatbagdMacro, RatbagdResolution, RatbagdButton, RatbagdLed, RatbagdUnavailable, RatbagError, RatbagErrorCode, RatbagErrorCapability # NOQA
|
||||
|
||||
|
||||
button_specials_strmap = {
|
||||
@@ -1520,8 +1520,8 @@ def open_ratbagd(ratbagd_process=None, verbose=0):
|
||||
try:
|
||||
r = Ratbagd()
|
||||
r.verbose = verbose
|
||||
except RatbagdDBusUnavailable:
|
||||
print("Unable to connect to ratbagd over dbus")
|
||||
except RatbagdUnavailable:
|
||||
print("Unable to connect to ratbagd")
|
||||
return None
|
||||
|
||||
if ratbagd_process is not None:
|
||||
|
||||
@@ -61,7 +61,7 @@ class RatbagErrorCode(IntEnum):
|
||||
RATBAG_ERROR_IMPLEMENTATION = -1004
|
||||
|
||||
|
||||
class RatbagdDBusUnavailable(Exception):
|
||||
class RatbagdUnavailable(Exception):
|
||||
"""Signals DBus is unavailable or the ratbagd daemon is not available."""
|
||||
pass
|
||||
|
||||
@@ -121,7 +121,7 @@ class _RatbagdDBus(GObject.GObject):
|
||||
try:
|
||||
_RatbagdDBus._dbus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
|
||||
except GLib.Error as e:
|
||||
raise RatbagdDBusUnavailable(e.message)
|
||||
raise RatbagdUnavailable(e.message)
|
||||
|
||||
ratbag1 = "org.freedesktop.ratbag1"
|
||||
if os.environ.get('RATBAGCTL_DEVEL'):
|
||||
@@ -142,10 +142,10 @@ class _RatbagdDBus(GObject.GObject):
|
||||
self._interface,
|
||||
None)
|
||||
except GLib.Error as e:
|
||||
raise RatbagdDBusUnavailable(e.message)
|
||||
raise RatbagdUnavailable(e.message)
|
||||
|
||||
if self._proxy.get_name_owner() is None:
|
||||
raise RatbagdDBusUnavailable("No one currently owns {}".format(ratbag1))
|
||||
raise RatbagdUnavailable("No one currently owns {}".format(ratbag1))
|
||||
|
||||
self._proxy.connect("g-properties-changed", self._on_properties_changed)
|
||||
|
||||
@@ -270,7 +270,7 @@ class Ratbagd(_RatbagdDBus):
|
||||
through ratbagd; actual interaction with the devices is via the
|
||||
RatbagdDevice, RatbagdProfile, RatbagdResolution and RatbagdButton objects.
|
||||
|
||||
Throws RatbagdDBusUnavailable when the DBus service is not available.
|
||||
Throws RatbagdUnavailable when the DBus service is not available.
|
||||
"""
|
||||
|
||||
__gsignals__ = {
|
||||
|
||||
Reference in New Issue
Block a user