Merge remote-tracking branch 'satreix/pep-e502' into develop

This commit is contained in:
rembo10
2016-04-05 11:57:48 +01:00
8 changed files with 22 additions and 23 deletions
+1 -2
View File
@@ -10,6 +10,5 @@
# E262 inline comment should start with '# ' # E262 inline comment should start with '# '
# E265 block comment should start with '# ' # E265 block comment should start with '# '
# E501 line too long (312 > 160 characters) # E501 line too long (312 > 160 characters)
# E502 the backslash is redundant between brackets ignore = E121,E122,E123,E124,E125,E126,E127,E128,E261,E262,E265,E501
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E261,E262,E265,E501,E502
max-line-length = 160 max-line-length = 160
+1 -1
View File
@@ -132,7 +132,7 @@ def initialize(config_file):
CONFIG.LOG_DIR = None CONFIG.LOG_DIR = None
if not QUIET: if not QUIET:
sys.stderr.write("Unable to create the log directory. " \ sys.stderr.write("Unable to create the log directory. "
"Logging to screen only.\n") "Logging to screen only.\n")
# Start the logger, disable console if needed # Start the logger, disable console if needed
+3 -3
View File
@@ -538,8 +538,8 @@ def preserve_torrent_directory(albumpath):
shutil.copytree(albumpath, new_folder) shutil.copytree(albumpath, new_folder)
return new_folder return new_folder
except Exception as e: except Exception as e:
logger.warn("Cannot copy/move files to temp folder: " + \ logger.warn("Cannot copy/move files to temp folder: " +
new_folder.decode(headphones.SYS_ENCODING, 'replace') + \ new_folder.decode(headphones.SYS_ENCODING, 'replace') +
". Not continuing. Error: " + str(e)) ". Not continuing. Error: " + str(e))
return None return None
@@ -684,7 +684,7 @@ def walk_directory(basedir, followlinks=True):
real_path = os.path.abspath(os.readlink(path)) real_path = os.path.abspath(os.readlink(path))
if real_path in traversed: if real_path in traversed:
logger.debug("Skipping '%s' since it is a symlink to " \ logger.debug("Skipping '%s' since it is a symlink to "
"'%s', which is already visited.", path, real_path) "'%s', which is already visited.", path, real_path)
else: else:
traversed.append(real_path) traversed.append(real_path)
+1 -1
View File
@@ -72,7 +72,7 @@ def listener():
# http://stackoverflow.com/questions/2009278 for more information. # http://stackoverflow.com/questions/2009278 for more information.
if e.errno == errno.EACCES: if e.errno == errno.EACCES:
logger.warning("Multiprocess logging disabled, because " logger.warning("Multiprocess logging disabled, because "
"current user cannot map shared memory. You won't see any" \ "current user cannot map shared memory. You won't see any"
"logging generated by the worker processed.") "logging generated by the worker processed.")
# Multiprocess logging may be disabled. # Multiprocess logging may be disabled.
+6 -6
View File
@@ -108,8 +108,8 @@ def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=Fal
[release_dict['artist_id'], release_dict['artist_name']]) [release_dict['artist_id'], release_dict['artist_name']])
if not artist: if not artist:
logger.warn("Continuing would add new artist '%s' (ID %s), " \ logger.warn("Continuing would add new artist '%s' (ID %s), "
"but database is frozen. Will skip postprocessing for " \ "but database is frozen. Will skip postprocessing for "
"album with rgid: %s", release_dict['artist_name'], "album with rgid: %s", release_dict['artist_name'],
release_dict['artist_id'], albumid) release_dict['artist_id'], albumid)
@@ -348,7 +348,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
# this test is just to keep pyflakes from complaining about an unused variable # this test is just to keep pyflakes from complaining about an unused variable
return return
except (FileTypeError, UnreadableFileError): except (FileTypeError, UnreadableFileError):
logger.error("Track file is not a valid media file: %s. Not " \ logger.error("Track file is not a valid media file: %s. Not "
"continuing.", downloaded_track.decode( "continuing.", downloaded_track.decode(
headphones.SYS_ENCODING, "replace")) headphones.SYS_ENCODING, "replace"))
return return
@@ -371,7 +371,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
fp.seek(0) fp.seek(0)
except IOError as e: except IOError as e:
logger.debug("Write check exact error: %s", e) logger.debug("Write check exact error: %s", e)
logger.error("Track file is not writable. This is required " \ logger.error("Track file is not writable. This is required "
"for some post processing steps: %s. Not continuing.", "for some post processing steps: %s. Not continuing.",
downloaded_track.decode(headphones.SYS_ENCODING, "replace")) downloaded_track.decode(headphones.SYS_ENCODING, "replace"))
if new_folder: if new_folder:
@@ -1436,7 +1436,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None, keep_orig
logger.info('No match found on MusicBrainz for: %s - %s', name, album) logger.info('No match found on MusicBrainz for: %s - %s', name, album)
# Fail here # Fail here
logger.info("Couldn't parse '%s' into any valid format. If adding " \ logger.info("Couldn't parse '%s' into any valid format. If adding "
"albums from another source, they must be in an 'Artist - Album " \ "albums from another source, they must be in an 'Artist - Album "
"[Year]' format, or end with the musicbrainz release group id.", "[Year]' format, or end with the musicbrainz release group id.",
folder_basename) folder_basename)
+7 -7
View File
@@ -119,10 +119,10 @@ def read_torrent_name(torrent_file, default_name=None):
return torrent_info["info"]["name"] return torrent_info["info"]["name"]
except KeyError: except KeyError:
if default_name: if default_name:
logger.warning("Couldn't get name from torrent file: %s. " \ logger.warning("Couldn't get name from torrent file: %s. "
"Defaulting to '%s'", e, default_name) "Defaulting to '%s'", e, default_name)
else: else:
logger.warning("Couldn't get name from torrent file: %s. No " \ logger.warning("Couldn't get name from torrent file: %s. No "
"default given", e) "default given", e)
# Return default # Return default
@@ -143,7 +143,7 @@ def calculate_torrent_hash(link, data=None):
info = bdecode(data)["info"] info = bdecode(data)["info"]
torrent_hash = sha1(bencode(info)).hexdigest() torrent_hash = sha1(bencode(info)).hexdigest()
else: else:
raise ValueError("Cannot calculate torrent hash without magnet link " \ raise ValueError("Cannot calculate torrent hash without magnet link "
"or data") "or data")
return torrent_hash.upper() return torrent_hash.upper()
@@ -842,16 +842,16 @@ def send_to_downloader(data, bestqual, album):
break break
else: else:
# No service succeeded # No service succeeded
logger.warning("Unable to convert magnet with hash " \ logger.warning("Unable to convert magnet with hash "
"'%s' into a torrent file.", torrent_hash) "'%s' into a torrent file.", torrent_hash)
return return
elif headphones.CONFIG.MAGNET_LINKS == 3: elif headphones.CONFIG.MAGNET_LINKS == 3:
torrent_to_file(download_path, data) torrent_to_file(download_path, data)
return return
else: else:
logger.error("Cannot save magnet link in blackhole. " \ logger.error("Cannot save magnet link in blackhole. "
"Please switch your torrent downloader to " \ "Please switch your torrent downloader to "
"Transmission, uTorrent or Deluge, or allow Headphones " \ "Transmission, uTorrent or Deluge, or allow Headphones "
"to open or convert magnet links") "to open or convert magnet links")
return return
else: else:
+1 -1
View File
@@ -164,7 +164,7 @@ def torrentAction(method, arguments):
whitelist_status_code=[401, 409]) whitelist_status_code=[401, 409])
if response.status_code == 401: if response.status_code == 401:
if auth: if auth:
logger.error("Username and/or password not accepted by " \ logger.error("Username and/or password not accepted by "
"Transmission") "Transmission")
else: else:
logger.error("Transmission authorization required") logger.error("Transmission authorization required")
+2 -2
View File
@@ -35,12 +35,12 @@ def initialize(options):
if not (https_cert and os.path.exists(https_cert)) or not ( if not (https_cert and os.path.exists(https_cert)) or not (
https_key and os.path.exists(https_key)): https_key and os.path.exists(https_key)):
if not create_https_certificates(https_cert, https_key): if not create_https_certificates(https_cert, https_key):
logger.warn("Unable to create certificate and key. Disabling " \ logger.warn("Unable to create certificate and key. Disabling "
"HTTPS") "HTTPS")
enable_https = False enable_https = False
if not (os.path.exists(https_cert) and os.path.exists(https_key)): if not (os.path.exists(https_cert) and os.path.exists(https_key)):
logger.warn("Disabled HTTPS because of missing certificate and " \ logger.warn("Disabled HTTPS because of missing certificate and "
"key.") "key.")
enable_https = False enable_https = False