Skip to content

Commit

Permalink
Merge branch 'master' into gtk4
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 3, 2023
2 parents 6915ed2 + 29570db commit 70de1ee
Show file tree
Hide file tree
Showing 7 changed files with 2,360 additions and 104 deletions.
8 changes: 7 additions & 1 deletion cozy/application.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gettext
import locale
import logging
import os
Expand Down Expand Up @@ -73,9 +74,14 @@ def __init__(self, localedir: str, pkgdatadir: str):
sys.excepthook = self.handle_exception
setup_thread_excepthook()

import gettext
# We need to call `locale.*textdomain` to get the strings in UI files translated
locale.bindtextdomain('com.github.geigi.cozy', localedir)
locale.textdomain('com.github.geigi.cozy')

# But also `gettext.*textdomain`, to make `_("foo")` in Python work as well
gettext.bindtextdomain('com.github.geigi.cozy', localedir)
gettext.textdomain('com.github.geigi.cozy')

gettext.install('com.github.geigi.cozy', localedir)

def do_startup(self):
Expand Down
10 changes: 8 additions & 2 deletions cozy/control/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
log = logging.getLogger("offline_cache")


class UnsupportedProperty(Exception):
pass


class Server:
def __init__(self, con, path):
method_outargs = {}
Expand Down Expand Up @@ -84,13 +88,15 @@ def on_method_call(self,
invocation.return_value(variant)
else:
invocation.return_value(None)
except UnsupportedProperty:
invocation.return_dbus_error("{}.Error.NotSupported".format(interface_name), "Unsupported property")
except Exception as e:
log.error(e)
reporter.exception("mpris", e)
reporter.error("mpris", "MPRIS method call failed with method name: {}".format(method_name))
if out_args:
reporter.error("mpris", "MPRIS method call failed with out_args: {}".format(out_args))
invocation.return_value(None)
invocation.return_dbus_error("{}.Error.Failed".format(interface_name), "Internal exception occurred")


class MPRIS(Server):
Expand Down Expand Up @@ -270,7 +276,7 @@ def Get(self, interface, property_name):
return GLib.Variant("d", self._player.volume)
else:
reporter.warning("mpris", "MPRIS required an unknown information: {}".format(property_name))
return None
raise UnsupportedProperty

def GetAll(self, interface):
ret = {}
Expand Down
Loading

0 comments on commit 70de1ee

Please sign in to comment.