From d46449577f588506ae9147224344fe6ba4c32239 Mon Sep 17 00:00:00 2001 From: boyska Date: Thu, 19 Jan 2017 11:02:04 +0100 Subject: [PATCH] lint: avoid redefining outer names or builtins --- larigira/mpc.py | 22 +++++++++++----------- larigira/unused.py | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/larigira/mpc.py b/larigira/mpc.py index 9229b9c..7b13e35 100644 --- a/larigira/mpc.py +++ b/larigira/mpc.py @@ -4,7 +4,7 @@ import signal import gevent from gevent.queue import Queue -from mpd import MPDClient, ConnectionError, CommandError +import mpd from .event import Monitor from .eventutils import ParentedLet, Timer @@ -13,7 +13,7 @@ from .unused import UnusedCleaner def get_mpd_client(conf): - client = MPDClient(use_unicode=True) + client = mpd.MPDClient(use_unicode=True) client.connect(conf['MPD_HOST'], conf['MPD_PORT']) return client @@ -39,7 +39,7 @@ class MpcWatcher(ParentedLet): yield('mpc', 'connect') status = self.client.idle()[0] - except (ConnectionError, ConnectionRefusedError, + except (mpd.ConnectionError, ConnectionRefusedError, FileNotFoundError) as exc: self.log.warning('Connection to MPD failed ({}: {})'. format(exc.__class__.__name__, exc)) @@ -62,10 +62,10 @@ class Player: self.events_enabled = True def _get_mpd(self): - mpd_client = MPDClient(use_unicode=True) + mpd_client = mpd.MPDClient(use_unicode=True) try: mpd_client.connect(self.conf['MPD_HOST'], self.conf['MPD_PORT']) - except (ConnectionError, ConnectionRefusedError, + except (mpd.ConnectionError, ConnectionRefusedError, FileNotFoundError) as exc: self.log.warning('Connection to MPD failed ({}: {})'. format(exc.__class__.__name__, exc)) @@ -82,12 +82,12 @@ class Player: if spec is None else spec def clear_everything_but_current_song(): - mpd = self._get_mpd() - current = mpd.currentsong() + mpdc = self._get_mpd() + current = mpdc.currentsong() pos = int(current.get('pos', 0)) - for song in mpd.playlistid(): + for song in mpdc.playlistid(): if int(song['pos']) != pos: - mpd.deleteid(song['id']) + mpdc.deleteid(song['id']) gevent.Greenlet.spawn(clear_everything_but_current_song) @@ -130,7 +130,7 @@ class Player: int(mpd_client.currentsong().get('pos', 0)) + 1 try: mpd_client.addid(uri, insert_pos) - except CommandError: + except mpd.CommandError: self.log.exception("Cannot insert song {}".format(uri)) self.tmpcleaner.watch(uri.strip()) @@ -161,7 +161,7 @@ class Controller(gevent.Greenlet): gevent.Greenlet.spawn(self.player.check_playlist) while True: value = self.q.get() - self.log.debug('<- %s' % str(value)) + self.log.debug('<- %s', str(value)) # emitter = value['emitter'] kind = value['kind'] args = value['args'] diff --git a/larigira/unused.py b/larigira/unused.py index 3b7d2a4..bdec089 100644 --- a/larigira/unused.py +++ b/larigira/unused.py @@ -58,8 +58,8 @@ class UnusedCleaner: def check_playlist(self): '''check playlist + internal watchlist to see what can be removed''' - mpd = self._get_mpd() - files_in_playlist = {song['file'] for song in mpd.playlistid() + mpdc = self._get_mpd() + files_in_playlist = {song['file'] for song in mpdc.playlistid() if song['file'].startswith('/')} for fpath in self.waiting_removal_files - files_in_playlist: # we can remove it!