Skip to content

Commit

Permalink
*: add or remove log (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven authored Jan 16, 2024
1 parent bbc8da9 commit e7994ff
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
17 changes: 12 additions & 5 deletions feeluown/gui/components/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from typing import Optional

from feeluown.app import App
from feeluown.excs import ProviderIOError
from feeluown.utils.aio import run_fn, run_afn
from feeluown.player import SongRadio
from feeluown.library import SongProtocol, VideoModel
from feeluown.library import SongProtocol, VideoModel, SupportsSongMV

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -81,7 +82,11 @@ def _hover_mv(self, action, data):

def mv_fetched_cb(future):
self._fetching_mv = False
mv: Optional[VideoModel] = future.result()
try:
mv: Optional[VideoModel] = future.result()
except ProviderIOError as e:
logger.error(f"fetch song mv failed {e}")
mv = None
if mv is not None:
try:
mv_action = action.menu().addAction(mv.title)
Expand All @@ -103,9 +108,11 @@ def mv_fetched_cb(future):
if data['mvs'] is None and self._fetching_mv is False:
logger.debug('fetch song.mv for actions')
song = data['song']
self._fetching_mv = True
task = run_fn(self._app.library.song_get_mv, song)
task.add_done_callback(mv_fetched_cb)
provider = self._app.library.get(song.source)
if provider is not None and isinstance(provider, SupportsSongMV):
self._fetching_mv = True
task = run_fn(provider.song_get_mv, song)
task.add_done_callback(mv_fetched_cb)

def _hover_artists(self, action, data):
# pylint: disable=unnecessary-direct-lambda-call
Expand Down
4 changes: 3 additions & 1 deletion feeluown/gui/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def get_from_cache(self, img_name):
return None

async def get(self, img_url, img_name):
if not img_url:
return None
if img_url.startswith('fuo://local'):
# Before, `models.uri.resolve` is uesd to handle these non-std paths,
# and it is not elegant in fact :(
Expand All @@ -45,7 +47,7 @@ async def get(self, img_url, img_name):
return provider.handle_with_path(img_url[11:])
fpath = self.cache.get(img_name)
if fpath is not None:
logger.info('read image:%s from cache', img_name)
logger.debug('read image:%s from cache', img_name)
with open(fpath, 'rb') as f:
content = f.read()
self.cache.update(img_name)
Expand Down
1 change: 0 additions & 1 deletion feeluown/gui/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def set_mode(self, mode):

def on_media_changed(self, media):
if not media:
logger.info('No media is played, set mode to none')
self.set_mode(Mode.none)

def on_video_format_changed(self, video_format):
Expand Down
4 changes: 2 additions & 2 deletions feeluown/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
self.server_error_signal = Signal()

def get(self, *args, **kw):
logger.info('request.get %s %s' % (args, kw))
logger.debug('request.get %s %s' % (args, kw))
if kw.get('timeout') is None:
kw['timeout'] = 1
try:
Expand All @@ -32,7 +32,7 @@ def get(self, *args, **kw):
return None

def post(self, *args, **kw):
logger.info('request.post %s %s' % (args, kw))
logger.debug('request.post %s %s' % (args, kw))
try:
res = requests.post(*args, **kw)
return res
Expand Down
3 changes: 2 additions & 1 deletion feeluown/webserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

logger = logging.getLogger(__name__)

sanic_app = Sanic('FeelUOwn')
# Disable sanic's logging so that it can use feeluown's logging system.
sanic_app = Sanic('FeelUOwn', configure_logging=False)


def resp(js):
Expand Down

0 comments on commit e7994ff

Please sign in to comment.