Every plugin uses its own logger

logging.getLogger(__name__) everywhere!
Several loggers prefixed every log message with [logername], which we
delete here.
This commit is contained in:
Bruno Cauet 2015-01-05 10:37:56 +01:00
parent fd2c57f736
commit b8211a3c4c
33 changed files with 144 additions and 149 deletions

View file

@ -23,7 +23,7 @@ from beets import logging
from beets.autotag.hooks import AlbumInfo, TrackInfo, Distance
from beets.plugins import BeetsPlugin
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class BeatportAPIError(Exception):
@ -205,14 +205,14 @@ class BeatportPlugin(BeetsPlugin):
try:
return self._get_tracks(query)
except BeatportAPIError as e:
log.debug(u'Beatport API Error: {0} (query: {1})', e, query)
log.debug(u'API Error: {0} (query: {1})', e, query)
return []
def album_for_id(self, release_id):
"""Fetches a release by its Beatport ID and returns an AlbumInfo object
or None if the release is not found.
"""
log.debug(u'Searching Beatport for release {0}', release_id)
log.debug(u'Searching for release {0}', release_id)
match = re.search(r'(^|beatport\.com/release/.+/)(\d+)$', release_id)
if not match:
return None
@ -224,7 +224,7 @@ class BeatportPlugin(BeetsPlugin):
"""Fetches a track by its Beatport ID and returns a TrackInfo object
or None if the track is not found.
"""
log.debug(u'Searching Beatport for track {0}', track_id)
log.debug(u'Searching for track {0}', track_id)
match = re.search(r'(^|beatport\.com/track/.+/)(\d+)$', track_id)
if not match:
return None

View file

@ -71,7 +71,7 @@ SAFE_COMMANDS = (
ITEM_KEYS_WRITABLE = set(MediaFile.fields()).intersection(Item._fields.keys())
# Loggers.
log = logging.getLogger('beets.bpd')
log = logging.getLogger(__name__)
global_log = logging.getLogger('beets')

View file

@ -19,7 +19,7 @@ import time
from beets import ui, logging
from beets.plugins import BeetsPlugin
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def bpm(max_strokes):

View file

@ -23,7 +23,7 @@ from itertools import tee, izip
from beets import logging
from beets import plugins, ui
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class BucketError(Exception):

View file

@ -32,7 +32,7 @@ COMMON_REL_THRESH = 0.6 # How many tracks must have an album in common?
MAX_RECORDINGS = 5
MAX_RELEASES = 5
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
# Stores the Acoustid match information for each track. This is
# populated when an import task begins and then used when searching for
@ -80,17 +80,17 @@ def acoustid_match(path):
# Ensure the response is usable and parse it.
if res['status'] != 'ok' or not res.get('results'):
log.debug(u'chroma: no match found')
log.debug(u'no match found')
return None
result = res['results'][0] # Best match.
if result['score'] < SCORE_THRESH:
log.debug(u'chroma: no results above threshold')
log.debug(u'no results above threshold')
return None
_acoustids[path] = result['id']
# Get recording and releases from the result.
if not result.get('recordings'):
log.debug(u'chroma: no recordings found')
log.debug(u'no recordings found')
return None
recording_ids = []
release_ids = []
@ -99,7 +99,7 @@ def acoustid_match(path):
if 'releases' in recording:
release_ids += [rel['id'] for rel in recording['releases']]
log.debug(u'chroma: matched recordings {0} on releases {1}',
log.debug(u'matched recordings {0} on releases {1}',
recording_ids, release_ids)
_matches[path] = recording_ids, release_ids

View file

@ -26,7 +26,7 @@ from beets.plugins import BeetsPlugin
from beetsplug.embedart import embed_item
from beets.util.confit import ConfigTypeError
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
_fs_lock = threading.Lock()
_temp_files = [] # Keep track of temporary transcoded files for deletion.

View file

@ -27,7 +27,7 @@ import re
import time
import json
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
# Silence spurious INFO log lines generated by urllib3.
urllib3_logger = logging.getLogger('requests.packages.urllib3')
@ -117,7 +117,7 @@ class DiscogsPlugin(BeetsPlugin):
try:
return self.get_albums(query)
except DiscogsAPIError as e:
log.debug(u'Discogs API Error: {0} (query: {1})', e, query)
log.debug(u'API Error: {0} (query: {1})', e, query)
return []
except ConnectionError as e:
log.debug(u'HTTP Connection Error: {0}', e)
@ -130,7 +130,7 @@ class DiscogsPlugin(BeetsPlugin):
if not self.discogs_client:
return
log.debug(u'Searching Discogs for release {0}', album_id)
log.debug(u'Searching for release {0}', album_id)
# Discogs-IDs are simple integers. We only look for those at the end
# of an input string as to avoid confusion with other metadata plugins.
# An optional bracket can follow the integer, as this is how discogs
@ -145,8 +145,7 @@ class DiscogsPlugin(BeetsPlugin):
getattr(result, 'title')
except DiscogsAPIError as e:
if e.message != '404 Not Found':
log.debug(u'Discogs API Error: {0} (query: {1})',
e, result._uri)
log.debug(u'API Error: {0} (query: {1})', e, result._uri)
return None
except ConnectionError as e:
log.debug(u'HTTP Connection Error: {0}', e)
@ -294,7 +293,7 @@ class DiscogsPlugin(BeetsPlugin):
if match:
medium, index = match.groups()
else:
log.debug(u'Invalid Discogs position: {0}', position)
log.debug(u'Invalid position: {0}', position)
medium = index = None
return medium or None, index or None

View file

@ -22,7 +22,7 @@ from beets.ui import decargs, print_obj, vararg_callback, Subcommand, UserError
from beets.util import command_output, displayable_path, subprocess
PLUGIN = 'duplicates'
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def _process_item(item, lib, copy=False, move=False, delete=False,

View file

@ -27,7 +27,7 @@ import pyechonest
import pyechonest.song
import pyechonest.track
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
# If a request at the EchoNest fails, we want to retry the request RETRIES
# times and wait between retries for RETRY_INTERVAL seconds.
@ -152,31 +152,30 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
except pyechonest.util.EchoNestAPIError as e:
if e.code == 3:
# reached access limit per minute
log.debug(u'echonest: rate-limited on try {0}; '
u'waiting {1} seconds',
log.debug(u'rate-limited on try {0}; waiting {1} seconds',
i + 1, RETRY_INTERVAL)
time.sleep(RETRY_INTERVAL)
elif e.code == 5:
# specified identifier does not exist
# no use in trying again.
log.debug(u'echonest: {0}', e)
log.debug(u'{0}', e)
return None
else:
log.error(u'echonest: {0}', e.args[0][0])
log.error(u'{0}', e.args[0][0])
return None
except (pyechonest.util.EchoNestIOError, socket.error) as e:
log.warn(u'echonest: IO error: {0}', e)
log.warn(u'IO error: {0}', e)
time.sleep(RETRY_INTERVAL)
except Exception as e:
# there was an error analyzing the track, status: error
log.debug(u'echonest: {0}', e)
log.debug(u'{0}', e)
return None
else:
break
else:
# If we exited the loop without breaking, then we used up all
# our allotted retries.
log.error(u'echonest request failed repeatedly')
log.error(u'request failed repeatedly')
return None
return result
@ -187,7 +186,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
seconds, it's considered a match.
"""
if not songs:
log.debug(u'echonest: no songs found')
log.debug(u'no songs found')
return
pick = None
@ -225,13 +224,13 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
# Look up the Echo Nest ID based on the MBID.
else:
if not item.mb_trackid:
log.debug(u'echonest: no ID available')
log.debug(u'no ID available')
return
mbid = 'musicbrainz:track:{0}'.format(item.mb_trackid)
track = self._echofun(pyechonest.track.track_from_id,
identifier=mbid)
if not track:
log.debug(u'echonest: lookup by MBID failed')
log.debug(u'lookup by MBID failed')
return
enid = track.song_id
@ -291,7 +290,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
fd, dest = tempfile.mkstemp(u'.ogg')
os.close(fd)
log.info(u'echonest: encoding {0} to {1}',
log.info(u'encoding {0} to {1}',
util.displayable_path(source),
util.displayable_path(dest))
@ -304,11 +303,11 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
try:
util.command_output(opts)
except (OSError, subprocess.CalledProcessError) as exc:
log.debug(u'echonest: encode failed: {0}', exc)
log.debug(u'encode failed: {0}', exc)
util.remove(dest)
return
log.info(u'echonest: finished encoding {0}',
log.info(u'finished encoding {0}',
util.displayable_path(source))
return dest
@ -317,7 +316,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
fd, dest = tempfile.mkstemp(u'.ogg')
os.close(fd)
log.info(u'echonest: truncating {0} to {1}',
log.info(u'truncating {0} to {1}',
util.displayable_path(source),
util.displayable_path(dest))
@ -330,11 +329,11 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
try:
util.command_output(opts)
except (OSError, subprocess.CalledProcessError) as exc:
log.debug(u'echonest: truncate failed: {0}', exc)
log.debug(u'truncate failed: {0}', exc)
util.remove(dest)
return
log.info(u'echonest: truncate encoding {0}',
log.info(u'truncate encoding {0}',
util.displayable_path(source))
return dest
@ -344,18 +343,18 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
"""
prepared = self.prepare_upload(item)
if not prepared:
log.debug(u'echonest: could not prepare file for upload')
log.debug(u'could not prepare file for upload')
return
source, tmp = prepared
log.info(u'echonest: uploading file, please be patient')
log.info(u'uploading file, please be patient')
track = self._echofun(pyechonest.track.track_from_filename,
filename=source)
if tmp is not None:
util.remove(tmp)
if not track:
log.debug(u'echonest: failed to upload file')
log.debug(u'failed to upload file')
return
# Sometimes we have a track but no song. I guess this happens for
@ -406,7 +405,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
for method in methods:
song = method(item)
if song:
log.debug(u'echonest: got song through {0}: {1} - {2} [{3}]',
log.debug(u'got song through {0}: {1} - {2} [{3}]',
method.__name__,
item.artist,
item.title,
@ -422,7 +421,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
for k, v in values.iteritems():
if k in ATTRIBUTES:
field = ATTRIBUTES[k]
log.debug(u'echonest: metadata: {0} = {1}', field, v)
log.debug(u'metadata: {0} = {1}', field, v)
if field == 'bpm':
item[field] = int(v)
else:
@ -434,7 +433,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
item['initial_key'] = key
if 'id' in values:
enid = values['id']
log.debug(u'echonest: metadata: {0} = {1}', ID_KEY, enid)
log.debug(u'metadata: {0} = {1}', ID_KEY, enid)
item[ID_KEY] = enid
# Write and save.
@ -461,7 +460,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
for field in ATTRIBUTES.values():
if not item.get(field):
return True
log.info(u'echonest: no update required')
log.info(u'no update required')
return False
def commands(self):
@ -476,7 +475,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
self.config.set_args(opts)
write = config['import']['write'].get(bool)
for item in lib.items(ui.decargs(args)):
log.info(u'echonest: {0} - {1}', item.artist, item.title)
log.info(u'{0} - {1}', item.artist, item.title)
if self.config['force'] or self.requires_update(item):
song = self.fetch_song(item)
if song:

View file

@ -29,7 +29,7 @@ from beets.util.artresizer import ArtResizer
from beets import config
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class EmbedCoverArtPlugin(BeetsPlugin):
@ -46,12 +46,12 @@ class EmbedCoverArtPlugin(BeetsPlugin):
if self.config['maxwidth'].get(int) and not ArtResizer.shared.local:
self.config['maxwidth'] = 0
log.warn(u"embedart: ImageMagick or PIL not found; "
log.warn(u"ImageMagick or PIL not found; "
u"'maxwidth' option ignored")
if self.config['compare_threshold'].get(int) and not \
ArtResizer.shared.can_compare:
self.config['compare_threshold'] = 0
log.warn(u"embedart: ImageMagick 6.8.7 or higher not installed; "
log.warn(u"ImageMagick 6.8.7 or higher not installed; "
u"'compare_threshold' option ignored")
def commands(self):
@ -122,17 +122,17 @@ def embed_item(item, imagepath, maxwidth=None, itempath=None,
if not art:
pass
else:
log.debug(u'embedart: media file contained art already {0}',
log.debug(u'media file contained art already {0}',
displayable_path(imagepath))
return
if maxwidth and not as_album:
imagepath = resize_image(imagepath, maxwidth)
try:
log.debug(u'embedart: embedding {0}', displayable_path(imagepath))
log.debug(u'embedding {0}', displayable_path(imagepath))
item['images'] = [_mediafile_image(imagepath, maxwidth)]
except IOError as exc:
log.error(u'embedart: could not read image file: {0}', exc)
log.error(u'could not read image file: {0}', exc)
else:
# We don't want to store the image in the database.
item.try_write(itempath)
@ -192,15 +192,15 @@ def check_art_similarity(item, imagepath, compare_threshold):
stdout, stderr = proc.communicate()
if proc.returncode:
if proc.returncode != 1:
log.warn(u'embedart: IM phashes compare failed for '
u'{0}, {1}', displayable_path(imagepath),
log.warn(u'IM phashes compare failed for {0}, {1}',
displayable_path(imagepath),
displayable_path(art))
return
phashDiff = float(stderr)
else:
phashDiff = float(stdout)
log.info(u'embedart: compare PHASH score is {0}', phashDiff)
log.info(u'compare PHASH score is {0}', phashDiff)
if phashDiff > compare_threshold:
return False

View file

@ -39,7 +39,7 @@ IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg']
CONTENT_TYPES = ('image/jpeg',)
DOWNLOAD_EXTENSION = '.jpg'
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
requests_session = requests.Session()
requests_session.headers = {'User-Agent': 'beets'}
@ -50,12 +50,12 @@ def _fetch_image(url):
actually be an image. If so, returns a path to the downloaded image.
Otherwise, returns None.
"""
log.debug(u'fetchart: downloading art: {0}', url)
log.debug(u'downloading art: {0}', url)
try:
with closing(requests_session.get(url, stream=True)) as resp:
if 'Content-Type' not in resp.headers \
or resp.headers['Content-Type'] not in CONTENT_TYPES:
log.debug(u'fetchart: not an image')
log.debug(u'not an image')
return
# Generate a temporary file with the correct extension.
@ -63,11 +63,11 @@ def _fetch_image(url):
as fh:
for chunk in resp.iter_content():
fh.write(chunk)
log.debug(u'fetchart: downloaded art to: {0}',
log.debug(u'downloaded art to: {0}',
util.displayable_path(fh.name))
return fh.name
except (IOError, requests.RequestException):
log.debug(u'fetchart: error fetching art')
log.debug(u'error fetching art')
# ART SOURCES ################################################################
@ -116,9 +116,9 @@ def aao_art(album):
# Get the page from albumart.org.
try:
resp = requests_session.get(AAO_URL, params={'asin': album.asin})
log.debug(u'fetchart: scraped art URL: {0}', resp.url)
log.debug(u'scraped art URL: {0}', resp.url)
except requests.RequestException:
log.debug(u'fetchart: error scraping art page')
log.debug(u'error scraping art page')
return
# Search the page for the image URL.
@ -127,7 +127,7 @@ def aao_art(album):
image_url = m.group(1)
yield image_url
else:
log.debug(u'fetchart: no image found on page')
log.debug(u'no image found on page')
# Google Images scraper.
@ -156,7 +156,7 @@ def google_art(album):
for myUrl in dataInfo:
yield myUrl['unescapedUrl']
except:
log.debug(u'fetchart: error scraping art page')
log.debug(u'error scraping art page')
return
@ -171,7 +171,7 @@ def itunes_art(album):
try:
itunes_album = itunes.search_album(search_string)[0]
except Exception as exc:
log.debug('fetchart: iTunes search failed: {0}', exc)
log.debug('iTunes search failed: {0}', exc)
return
if itunes_album.get_artwork()['100']:
@ -179,9 +179,9 @@ def itunes_art(album):
big_url = small_url.replace('100x100', '1200x1200')
yield big_url
else:
log.debug(u'fetchart: album has no artwork in iTunes Store')
log.debug(u'album has no artwork in iTunes Store')
except IndexError:
log.debug(u'fetchart: album not found in iTunes Store')
log.debug(u'album not found in iTunes Store')
# Art from the filesystem.
@ -215,13 +215,13 @@ def art_in_path(path, cover_names, cautious):
cover_pat = r"(\b|_)({0})(\b|_)".format('|'.join(cover_names))
for fn in images:
if re.search(cover_pat, os.path.splitext(fn)[0], re.I):
log.debug(u'fetchart: using well-named art file {0}',
log.debug(u'using well-named art file {0}',
util.displayable_path(fn))
return os.path.join(path, fn)
# Fall back to any image in the folder.
if images and not cautious:
log.debug(u'fetchart: using fallback art file {0}',
log.debug(u'using fallback art file {0}',
util.displayable_path(images[0]))
return os.path.join(path, images[0])

View file

@ -22,7 +22,7 @@ from beets.ui import decargs
import os
log = logging.getLogger('beets.freedesktop')
log = logging.getLogger(__name__)
def process_query(lib, opts, args):
@ -37,7 +37,7 @@ def process_album(album):
artfile = os.path.split(fullartpath)[1]
create_file(albumpath, artfile)
else:
log.debug(u'freedesktop: album has no art')
log.debug(u'album has no art')
def create_file(albumpath, artfile):

View file

@ -22,7 +22,7 @@ from beets.util import displayable_path
from beets import config
from beets import logging
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def split_on_feat(artist):

View file

@ -37,7 +37,7 @@ def summary(task):
class IHatePlugin(BeetsPlugin):
_log = logging.getLogger('beets')
_log = logging.getLogger(__name__)
def __init__(self):
super(IHatePlugin, self).__init__()
@ -69,15 +69,15 @@ class IHatePlugin(BeetsPlugin):
if task.choice_flag == action.APPLY:
if skip_queries or warn_queries:
self._log.debug(u'[ihate] processing your hate')
self._log.debug(u'processing your hate')
if self.do_i_hate_this(task, skip_queries):
task.choice_flag = action.SKIP
self._log.info(u'[ihate] skipped: {0}', summary(task))
self._log.info(u'skipped: {0}', summary(task))
return
if self.do_i_hate_this(task, warn_queries):
self._log.info(u'[ihate] you maybe hate this: {0}',
self._log.info(u'you may hate this: {0}',
summary(task))
else:
self._log.debug(u'[ihate] nothing to do')
self._log.debug(u'nothing to do')
else:
self._log.debug(u'[ihate] user made a decision, nothing to do')
self._log.debug(u'user made a decision, nothing to do')

View file

@ -13,7 +13,7 @@ from beets import config
from beets import util
from beets.plugins import BeetsPlugin
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class ImportAddedPlugin(BeetsPlugin):

View file

@ -25,7 +25,7 @@ from beets.util import normpath, syspath, bytestring_path
from beets import config, logging
M3U_DEFAULT_NAME = 'imported.m3u'
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class ImportFeedsPlugin(BeetsPlugin):

View file

@ -24,7 +24,7 @@ from beets import mediafile
from beets.util import displayable_path, normpath, syspath
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def run(lib, opts, args):

View file

@ -20,7 +20,7 @@ import itertools
from beets.plugins import BeetsPlugin
from beets import config, logging
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
FUNC_NAME = u'__INLINE_FUNC__'
@ -111,14 +111,14 @@ class InlinePlugin(BeetsPlugin):
# Item fields.
for key, view in itertools.chain(config['item_fields'].items(),
config['pathfields'].items()):
log.debug(u'inline: adding item field {0}', key)
log.debug(u'adding item field {0}', key)
func = compile_inline(view.get(unicode), False)
if func is not None:
self.template_fields[key] = func
# Album fields.
for key, view in config['album_fields'].items():
log.debug(u'inline: adding album field {0}', key)
log.debug(u'adding album field {0}', key)
func = compile_inline(view.get(unicode), True)
if func is not None:
self.album_template_fields[key] = func

View file

@ -23,7 +23,7 @@ from beets import util
from beets.plugins import BeetsPlugin
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class KeyFinderPlugin(BeetsPlugin):
@ -62,7 +62,7 @@ class KeyFinderPlugin(BeetsPlugin):
try:
key = util.command_output([bin, '-f', item.path])
except (subprocess.CalledProcessError, OSError) as exc:
log.error(u'KeyFinder execution failed: {0}', exc)
log.error(u'execution failed: {0}', exc)
continue
item['initial_key'] = key

View file

@ -31,7 +31,7 @@ from beets.util import normpath, plurality
from beets import config
from beets import library
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
LASTFM = pylast.LastFMNetwork(api_key=plugins.LASTFM_KEY)

View file

@ -20,7 +20,7 @@ from beets import plugins
from beets import logging
from beets.dbcore import types
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
API_URL = 'http://ws.audioscrobbler.com/2.0/'
@ -65,7 +65,7 @@ def import_lastfm(lib):
retry_limit = config['lastimport']['retry_limit'].get(int)
# Iterate through a yet to be known page total count
while page_current < page_total:
log.info('lastimport: Querying page #{0}{1}...',
log.info('Querying page #{0}{1}...',
page_current + 1,
'/{}'.format(page_total) if page_total > 1 else '')
@ -83,22 +83,22 @@ def import_lastfm(lib):
unknown_total += unknown
break
else:
log.error('lastimport: ERROR: unable to read page #{0}',
log.error('ERROR: unable to read page #{0}',
page_current + 1)
if retry < retry_limit:
log.info(
'lastimport: Retrying page #{0}... ({1}/{2} retry)',
'Retrying page #{0}... ({1}/{2} retry)',
page_current + 1, retry + 1, retry_limit
)
else:
log.error('lastimport: FAIL: unable to fetch page #{0}, ',
log.error('FAIL: unable to fetch page #{0}, ',
'tried {1} times', page_current, retry + 1)
page_current += 1
log.info('lastimport: ... done!')
log.info('lastimport: finished processing {0} song pages', page_total)
log.info('lastimport: {0} unknown play-counts', unknown_total)
log.info('lastimport: {0} play-counts imported', found_total)
log.info('... done!')
log.info('finished processing {0} song pages', page_total)
log.info('{0} unknown play-counts', unknown_total)
log.info('{0} play-counts imported', found_total)
def fetch_tracks(user, page, limit):
@ -116,8 +116,7 @@ def process_tracks(lib, tracks):
total = len(tracks)
total_found = 0
total_fails = 0
log.info('lastimport: Received {0} tracks in this page, processing...',
total)
log.info('Received {0} tracks in this page, processing...', total)
for num in xrange(0, total):
song = ''
@ -128,7 +127,7 @@ def process_tracks(lib, tracks):
if 'album' in tracks[num]:
album = tracks[num]['album'].get('name', '').strip()
log.debug(u'lastimport: query: {0} - {1} ({2})', artist, title, album)
log.debug(u'query: {0} - {1} ({2})', artist, title, album)
# First try to query by musicbrainz's trackid
if trackid:
@ -138,7 +137,7 @@ def process_tracks(lib, tracks):
# Otherwise try artist/title/album
if not song:
log.debug(u'lastimport: no match for mb_trackid {0}, trying by '
log.debug(u'no match for mb_trackid {0}, trying by '
u'artist/title/album', trackid)
query = dbcore.AndQuery([
dbcore.query.SubstringQuery('artist', artist),
@ -149,7 +148,7 @@ def process_tracks(lib, tracks):
# If not, try just artist/title
if not song:
log.debug(u'lastimport: no album match, trying by artist/title')
log.debug(u'no album match, trying by artist/title')
query = dbcore.AndQuery([
dbcore.query.SubstringQuery('artist', artist),
dbcore.query.SubstringQuery('title', title)
@ -159,7 +158,7 @@ def process_tracks(lib, tracks):
# Last resort, try just replacing to utf-8 quote
if not song:
title = title.replace("'", u'\u2019')
log.debug(u'lastimport: no title match, trying utf-8 single quote')
log.debug(u'no title match, trying utf-8 single quote')
query = dbcore.AndQuery([
dbcore.query.SubstringQuery('artist', artist),
dbcore.query.SubstringQuery('title', title)
@ -169,7 +168,7 @@ def process_tracks(lib, tracks):
if song:
count = int(song.get('play_count', 0))
new_count = int(tracks[num]['playcount'])
log.debug(u'lastimport: match: {0} - {1} ({2}) '
log.debug(u'match: {0} - {1} ({2}) '
u'updating: play_count {3} => {4}',
song.artist, song.title, song.album, count, new_count)
song['play_count'] = new_count
@ -177,11 +176,11 @@ def process_tracks(lib, tracks):
total_found += 1
else:
total_fails += 1
log.info(u'lastimport: - No match: {0} - {1} ({2})',
log.info(u' - No match: {0} - {1} ({2})',
artist, title, album)
if total_fails > 0:
log.info('lastimport: Acquired {0}/{1} play-counts ({2} unknown)',
log.info('Acquired {0}/{1} play-counts ({2} unknown)',
total_found, total, total_fails)
return total_found, total_fails

View file

@ -32,7 +32,7 @@ from beets import config, ui
# Global logger.
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
DIV_RE = re.compile(r'<(/?)div>?', re.I)
COMMENT_RE = re.compile(r'<!--.*-->', re.S)

View file

@ -26,7 +26,7 @@ import re
SUBMISSION_CHUNK_SIZE = 200
UUID_REGEX = r'^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}$'
log = logging.getLogger('beets.bpd')
log = logging.getLogger(__name__)
def mb_call(func, *args, **kwargs):

View file

@ -20,7 +20,7 @@ from beets.autotag import hooks
from beets import config
from collections import defaultdict
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def mbsync_singletons(lib, query, move, pretend, write):

View file

@ -20,8 +20,7 @@ from beets.library import Item
from beets.plugins import BeetsPlugin
from beets.ui import decargs, print_obj, Subcommand
PLUGIN = 'missing'
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def _missing_count(album):
@ -42,8 +41,8 @@ def _missing(album):
for track_info in getattr(album_info, 'tracks', []):
if track_info.track_id not in item_mbids:
item = _item(track_info, album_info, album.id)
log.debug(u'{0}: track {1} in album {2}',
PLUGIN, track_info.track_id, album_info.album_id)
log.debug(u'track {1} in album {2}',
track_info.track_id, album_info.album_id)
yield item

View file

@ -27,7 +27,7 @@ from beets import library
from beets.util import displayable_path
from beets.dbcore import types
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
# If we lose the connection, how many times do we want to retry and how
# much time should we wait between retries?
@ -71,7 +71,7 @@ class MPDClientWrapper(object):
if host[0] in ['/', '~']:
host = os.path.expanduser(host)
log.info(u'mpdstats: connecting to {0}:{1}', host, port)
log.info(u'connecting to {0}:{1}', host, port)
try:
self.client.connect(host, port)
except socket.error as e:
@ -99,7 +99,7 @@ class MPDClientWrapper(object):
try:
return getattr(self.client, command)()
except (select.error, mpd.ConnectionError) as err:
log.error(u'mpdstats: {0}', err)
log.error(u'{0}', err)
if retries <= 0:
# if we exited without breaking, we couldn't reconnect in time :(
@ -171,7 +171,7 @@ class MPDStats(object):
if item:
return item
else:
log.info(u'mpdstats: item not found: {0}', displayable_path(path))
log.info(u'item not found: {0}', displayable_path(path))
@staticmethod
def update_item(item, attribute, value=None, increment=None):
@ -190,7 +190,7 @@ class MPDStats(object):
item[attribute] = value
item.store()
log.debug(u'mpdstats: updated: {0} = {1} [{2}]',
log.debug(u'updated: {0} = {1} [{2}]',
attribute,
item[attribute],
displayable_path(item.path))
@ -229,16 +229,16 @@ class MPDStats(object):
"""Updates the play count of a song.
"""
self.update_item(song['beets_item'], 'play_count', increment=1)
log.info(u'mpdstats: played {0}', displayable_path(song['path']))
log.info(u'played {0}', displayable_path(song['path']))
def handle_skipped(self, song):
"""Updates the skip count of a song.
"""
self.update_item(song['beets_item'], 'skip_count', increment=1)
log.info(u'mpdstats: skipped {0}', displayable_path(song['path']))
log.info(u'skipped {0}', displayable_path(song['path']))
def on_stop(self, status):
log.info(u'mpdstats: stop')
log.info(u'stop')
if self.now_playing:
self.handle_song_change(self.now_playing)
@ -246,7 +246,7 @@ class MPDStats(object):
self.now_playing = None
def on_pause(self, status):
log.info(u'mpdstats: pause')
log.info(u'pause')
self.now_playing = None
def on_play(self, status):
@ -257,7 +257,7 @@ class MPDStats(object):
return
if is_url(path):
log.info(u'mpdstats: playing stream {0}', displayable_path(path))
log.info(u'playing stream {0}', displayable_path(path))
return
played, duration = map(int, status['time'].split(':', 1))
@ -266,7 +266,7 @@ class MPDStats(object):
if self.now_playing and self.now_playing['path'] != path:
self.handle_song_change(self.now_playing)
log.info(u'mpdstats: playing {0}', displayable_path(path))
log.info(u'playing {0}', displayable_path(path))
self.now_playing = {
'started': time.time(),
@ -291,7 +291,7 @@ class MPDStats(object):
if handler:
handler(status)
else:
log.debug(u'mpdstats: unhandled status "{0}"', status)
log.debug(u'unhandled status "{0}"', status)
events = self.mpd.events()

View file

@ -25,7 +25,7 @@ import platform
import shlex
from tempfile import NamedTemporaryFile
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def play_music(lib, opts, args):
@ -105,7 +105,7 @@ def play_music(lib, opts, args):
util.displayable_path(command[0]),
output.decode('utf8', 'ignore'))
else:
log.debug(u'play: no output')
log.debug(u'no output')
ui.print_(u'Playing {0} {1}.'.format(len(selection), item_type))

View file

@ -25,7 +25,7 @@ from beets.plugins import BeetsPlugin
from beets.util import syspath, command_output, displayable_path
from beets import config
log = logging.getLogger('beets.replaygain')
log = logging.getLogger(__name__)
# Utilities.
@ -135,7 +135,7 @@ class CommandBackend(Backend):
supported_items = filter(self.format_supported, album.items())
if len(supported_items) != len(album.items()):
log.debug(u'replaygain: tracks are of unsupported format')
log.debug(u'tracks are of unsupported format')
return AlbumGain(None, [])
output = self.compute_gain(supported_items, True)
@ -180,11 +180,10 @@ class CommandBackend(Backend):
cmd = cmd + ['-d', str(self.gain_offset)]
cmd = cmd + [syspath(i.path) for i in items]
log.debug(u'replaygain: analyzing {0} files', len(items))
log.debug(u"replaygain: executing {0}",
" ".join(map(displayable_path, cmd)))
log.debug(u'analyzing {0} files', len(items))
log.debug(u"executing {0}", " ".join(map(displayable_path, cmd)))
output = call(cmd)
log.debug(u'replaygain: analysis finished')
log.debug(u'analysis finished')
results = self.parse_tool_output(output,
len(items) + (1 if is_album else 0))
@ -199,7 +198,7 @@ class CommandBackend(Backend):
for line in text.split('\n')[1:num_lines + 1]:
parts = line.split('\t')
if len(parts) != 6 or parts[0] == 'File':
log.debug(u'replaygain: bad tool output: {0}', text)
log.debug(u'bad tool output: {0}', text)
raise ReplayGainError('mp3gain failed')
d = {
'file': parts[0],
@ -651,7 +650,7 @@ class ReplayGainPlugin(BeetsPlugin):
item.rg_track_peak = track_gain.peak
item.store()
log.debug(u'replaygain: applied track gain {0}, peak {1}',
log.debug(u'applied track gain {0}, peak {1}',
item.rg_track_gain, item.rg_track_peak)
def store_album_gain(self, album, album_gain):
@ -659,7 +658,7 @@ class ReplayGainPlugin(BeetsPlugin):
album.rg_album_peak = album_gain.peak
album.store()
log.debug(u'replaygain: applied album gain {0}, peak {1}',
log.debug(u'applied album gain {0}, peak {1}',
album.rg_album_gain, album.rg_album_peak)
def handle_album(self, album, write):

View file

@ -23,7 +23,7 @@ from beets import logging
from beets import ui
from beets import library
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
def rewriter(field, rules):

View file

@ -23,7 +23,7 @@ from beets import util
from beets import config
from beets import mediafile
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
_MUTAGEN_FORMATS = {
'asf': 'ASF',

View file

@ -7,7 +7,7 @@ from beets.ui import decargs
from beets import ui, logging
from requests.exceptions import HTTPError
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class SpotifyPlugin(BeetsPlugin):

View file

@ -29,7 +29,7 @@ FORMAT = u'{0}, {1}'
class ThePlugin(BeetsPlugin):
_instance = None
_log = logging.getLogger('beets')
_log = logging.getLogger(__name__)
the = True
a = True
@ -56,17 +56,17 @@ class ThePlugin(BeetsPlugin):
try:
re.compile(p)
except re.error:
self._log.error(u'[the] invalid pattern: {0}', p)
self._log.error(u'invalid pattern: {0}', p)
else:
if not (p.startswith('^') or p.endswith('$')):
self._log.warn(u'[the] warning: \"{0}\" will not '
'match string start/end', p)
self._log.warn(u'warning: \"{0}\" will not '
u'match string start/end', p)
if self.config['a']:
self.patterns = [PATTERN_A] + self.patterns
if self.config['the']:
self.patterns = [PATTERN_THE] + self.patterns
if not self.patterns:
self._log.warn(u'[the] no patterns defined!')
self._log.warn(u'no patterns defined!')
def unthe(self, text, pattern):
"""Moves pattern in the path format string or strips it
@ -99,7 +99,7 @@ class ThePlugin(BeetsPlugin):
r = self.unthe(text, p)
if r != text:
break
self._log.debug(u'[the] \"{0}\" -> \"{1}\"', text, r)
self._log.debug(u'\"{0}\" -> \"{1}\"', text, r)
return r
else:
return u''

View file

@ -24,7 +24,7 @@ from beets.util import confit
__author__ = 'baobab@heresiarch.info'
__version__ = '0.10'
log = logging.getLogger('beets')
log = logging.getLogger(__name__)
class ZeroPlugin(BeetsPlugin):
@ -48,11 +48,11 @@ class ZeroPlugin(BeetsPlugin):
for field in self.config['fields'].as_str_seq():
if field in ('id', 'path', 'album_id'):
log.warn(u'[zero] field \'{0}\' ignored, zeroing '
log.warn(u'field \'{0}\' ignored, zeroing '
u'it would be dangerous', field)
continue
if field not in MediaFile.fields():
log.error(u'[zero] invalid field: {0}', field)
log.error(u'invalid field: {0}', field)
continue
try:
@ -64,7 +64,7 @@ class ZeroPlugin(BeetsPlugin):
def import_task_choice_event(self, session, task):
"""Listen for import_task_choice event."""
if task.choice_flag == action.ASIS and not self.warned:
log.warn(u'[zero] cannot zero in \"as-is\" mode')
log.warn(u'cannot zero in \"as-is\" mode')
self.warned = True
# TODO request write in as-is mode
@ -85,7 +85,7 @@ class ZeroPlugin(BeetsPlugin):
by `self.patterns`.
"""
if not self.patterns:
log.warn(u'[zero] no fields, nothing to do')
log.warn(u'no fields, nothing to do')
return
for field, patterns in self.patterns.items():
@ -97,5 +97,5 @@ class ZeroPlugin(BeetsPlugin):
match = patterns is True
if match:
log.debug(u'[zero] {0}: {1} -> None', field, value)
log.debug(u'{0}: {1} -> None', field, value)
tags[field] = None