[gnome-music/wip/mschraal/utils-fix-3.36] utils: Catch file info query error
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/utils-fix-3.36] utils: Catch file info query error
- Date: Tue, 22 Sep 2020 15:22:44 +0000 (UTC)
commit 6954a2d9c7e1d69244377e8cfa9084f2e7c068d3
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jul 8 00:07:13 2020 +0200
utils: Catch file info query error
Add and clarify FIXME comments for future improvements.
Related: #401
gnomemusic/utils.py | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index b00f5ec1..7302936a 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -27,9 +27,11 @@ import re
import unicodedata
from gettext import gettext as _
-from gi.repository import Gio
+from gi.repository import Gio, GLib
from gi._gi import pygobject_new_full
+from gnomemusic.musiclogger import MusicLogger
+
class SongStateIcon(Enum):
"""Enum for icons used in song playing and validation"""
@@ -98,12 +100,21 @@ def get_media_title(item):
if not title:
url = item.get_url()
- # FIXME
+ # FIXME: This and the later occurance are user facing strings,
+ # but they ideally should never be seen. A media should always
+ # contain a URL or we can not play it, in that case it should
+ # be removed.
if url is None:
return "NO URL"
file_ = Gio.File.new_for_uri(url)
- fileinfo = file_.query_info(
- "standard::display-name", Gio.FileQueryInfoFlags.NONE, None)
+ try:
+ # FIXME: query_info is not async.
+ fileinfo = file_.query_info(
+ "standard::display-name", Gio.FileQueryInfoFlags.NONE, None)
+ except GLib.Error as error:
+ MusicLogger().warning(
+ "Error: {}, {}".format(error.domain, error.message))
+ return "NO URL"
title = fileinfo.get_display_name()
title = title.replace("_", " ")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]