[gnome-music/wip/mschraal/glib-logging: 58/65] albumartcache: New logger
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/glib-logging: 58/65] albumartcache: New logger
- Date: Sat, 1 Feb 2020 15:21:19 +0000 (UTC)
commit 3452850de81333f55f5194065da005ec5c8d6214
Author: Marinus Schraal <mschraal gnome org>
Date: Sat Feb 1 15:16:42 2020 +0100
albumartcache: New logger
gnomemusic/albumartcache.py | 48 ---------------------------------------------
1 file changed, 48 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 7861cf84..fbfd1f0f 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -23,7 +23,6 @@
# delete this exception statement from your version.
from enum import Enum
-import logging
from math import pi
import os
@@ -34,11 +33,9 @@ gi.require_version('MediaArt', '2.0')
from gi.repository import (Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk, MediaArt,
Gst, GstTag, GstPbutils)
-from gnomemusic import log
from gnomemusic.musiclogger import MusicLogger
-@log
def lookup_art_file_from_cache(coresong):
"""Lookup MediaArt cache art of an album or song.
@@ -60,7 +57,6 @@ def lookup_art_file_from_cache(coresong):
return thumb_file
-@log
def _make_icon_frame(icon_surface, art_size=None, scale=1, default_icon=False):
border = 3
degrees = pi / 180
@@ -128,14 +124,9 @@ class DefaultIcon(GObject.GObject):
_cache = {}
_default_theme = Gtk.IconTheme.get_default()
- def __repr__(self):
- return '<DefaultIcon>'
-
- @log
def __init__(self):
super().__init__()
- @log
def _make_default_icon(self, icon_type, art_size, scale):
icon_info = self._default_theme.lookup_icon_for_scale(
icon_type.value, art_size.width / 3, scale, 0)
@@ -145,7 +136,6 @@ class DefaultIcon(GObject.GObject):
return icon_surface
- @log
def get(self, icon_type, art_size, scale=1):
"""Returns the requested symbolic icon
@@ -194,10 +184,6 @@ class Art(GObject.GObject):
self.width = width
self.height = height
- def __repr__(self):
- return '<Art>'
-
- @log
def __init__(self, size, coresong, scale=1):
super().__init__()
@@ -211,7 +197,6 @@ class Art(GObject.GObject):
self._surface = None
self._scale = scale
- @log
def lookup(self):
"""Starts the art lookup sequence"""
if self._in_blacklist():
@@ -223,14 +208,12 @@ class Art(GObject.GObject):
cache.connect('hit', self._cache_hit)
cache.query(self._coresong)
- @log
def _cache_miss(self, klass):
embedded_art = EmbeddedArt()
embedded_art.connect('found', self._embedded_art_found)
embedded_art.connect('unavailable', self._embedded_art_unavailable)
embedded_art.query(self._coresong)
- @log
def _cache_hit(self, klass, pixbuf):
surface = Gdk.cairo_surface_create_from_pixbuf(
pixbuf, self._scale, None)
@@ -239,7 +222,6 @@ class Art(GObject.GObject):
self.emit('finished')
- @log
def _embedded_art_found(self, klass):
cache = Cache()
# In case of an error in local art retrieval, there are two
@@ -252,7 +234,6 @@ class Art(GObject.GObject):
cache.connect('hit', self._cache_hit)
cache.query(self._coresong)
- @log
def _embedded_art_unavailable(self, klass):
remote_art = RemoteArt()
remote_art.connect('retrieved', self._remote_art_retrieved)
@@ -260,30 +241,25 @@ class Art(GObject.GObject):
remote_art.connect('no-remote-sources', self._remote_art_no_sources)
remote_art.query(self._coresong)
- @log
def _remote_art_retrieved(self, klass):
cache = Cache()
cache.connect('miss', self._remote_art_unavailable)
cache.connect('hit', self._cache_hit)
cache.query(self._coresong)
- @log
def _remote_art_unavailable(self, klass):
self._add_to_blacklist()
self._no_art_available()
- @log
def _remote_art_no_sources(self, klass):
self._no_art_available()
- @log
def _no_art_available(self):
self._surface = DefaultIcon().get(
DefaultIcon.Type.MUSIC, self._size, self._scale)
self.emit('finished')
- @log
def _add_to_blacklist(self):
# FIXME: coresong can be a CoreAlbum
try:
@@ -298,7 +274,6 @@ class Art(GObject.GObject):
album_stripped = MediaArt.strip_invalid_entities(album)
self._blacklist[artist].append(album_stripped)
- @log
def _in_blacklist(self):
# FIXME: coresong can be a CoreAlbum
try:
@@ -334,10 +309,6 @@ class Cache(GObject.GObject):
'hit': (GObject.SignalFlags.RUN_FIRST, None, (GObject.GObject, ))
}
- def __repr__(self):
- return '<Cache>'
-
- @log
def __init__(self):
super().__init__()
@@ -353,7 +324,6 @@ class Cache(GObject.GObject):
"Error: {}, {}".format(error.domain, error.message))
return
- @log
def query(self, coresong):
"""Start the cache query
@@ -367,7 +337,6 @@ class Cache(GObject.GObject):
self.emit('miss')
- @log
def _open_stream(self, thumb_file, result, arguments):
try:
stream = thumb_file.read_finish(result)
@@ -380,7 +349,6 @@ class Cache(GObject.GObject):
GdkPixbuf.Pixbuf.new_from_stream_async(
stream, None, self._pixbuf_loaded, None)
- @log
def _pixbuf_loaded(self, stream, result, data):
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(result)
@@ -393,7 +361,6 @@ class Cache(GObject.GObject):
stream.close_async(GLib.PRIORITY_LOW, None, self._close_stream, None)
self.emit('hit', pixbuf)
- @log
def _close_stream(self, stream, result, data):
try:
stream.close_finish(result)
@@ -417,7 +384,6 @@ class EmbeddedArt(GObject.GObject):
def __repr__(self):
return '<EmbeddedArt>'
- @log
def __init__(self):
super().__init__()
@@ -438,7 +404,6 @@ class EmbeddedArt(GObject.GObject):
self._coresong = None
self._path = None
- @log
def query(self, coresong):
"""Start the local query
@@ -488,7 +453,6 @@ class EmbeddedArt(GObject.GObject):
discoverer.stop()
return
- @log
def _discovered(self, discoverer, info, error):
tags = info.get_tags()
index = 0
@@ -534,7 +498,6 @@ class EmbeddedArt(GObject.GObject):
self._lookup_cover_in_directory()
- @log
def _lookup_cover_in_directory(self):
# Find local art in cover.jpeg files.
self._media_art.uri_async(
@@ -542,7 +505,6 @@ class EmbeddedArt(GObject.GObject):
self._coresong.props.url, self._artist, self._album,
GLib.PRIORITY_LOW, None, self._uri_async_cb, None)
- @log
def _uri_async_cb(self, src, result, data):
try:
success = self._media_art.uri_finish(result)
@@ -574,10 +536,6 @@ class RemoteArt(GObject.GObject):
'no-remote-sources': (GObject.SignalFlags.RUN_FIRST, None, ())
}
- def __repr__(self):
- return '<RemoteArt>'
-
- @log
def __init__(self):
super().__init__()
@@ -588,7 +546,6 @@ class RemoteArt(GObject.GObject):
self._coresong = None
self._grilo = None
- @log
def query(self, coresong):
"""Start the remote query
@@ -627,7 +584,6 @@ class RemoteArt(GObject.GObject):
self._grilo.get_album_art_for_item(
self._coresong, self._remote_album_art)
- @log
def _delete_callback(self, src, result, data):
try:
src.delete_finish(result)
@@ -635,7 +591,6 @@ class RemoteArt(GObject.GObject):
self._log.warning(
"Error: {}, {}".format(error.domain, error.message))
- @log
def _splice_callback(self, src, result, data):
tmp_file, iostream = data
@@ -671,7 +626,6 @@ class RemoteArt(GObject.GObject):
tmp_file.delete_async(
GLib.PRIORITY_LOW, None, self._delete_callback, None)
- @log
def _close_iostream_callback(self, src, result, data):
try:
src.close_finish(result)
@@ -679,7 +633,6 @@ class RemoteArt(GObject.GObject):
self._log.warning(
"Error: {}, {}".format(error.domain, error.message))
- @log
def _read_callback(self, src, result, data):
try:
istream = src.read_finish(result)
@@ -705,7 +658,6 @@ class RemoteArt(GObject.GObject):
| Gio.OutputStreamSpliceFlags.CLOSE_TARGET, GLib.PRIORITY_LOW,
None, self._splice_callback, [tmp_file, iostream])
- @log
def _remote_album_art(self, source, param, item, count, error):
if error:
self._log.warning("Grilo error {}".format(error))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]