Fix PEP8 for bare exceptions

This commit is contained in:
Labrys of Knossos 2018-12-26 11:29:38 -05:00 committed by Lizband
parent 52c6096b6a
commit 018ded07d6
13 changed files with 126 additions and 126 deletions

View file

@ -31,7 +31,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
try: try:
encoded, input_directory1 = char_replace(input_directory) encoded, input_directory1 = char_replace(input_directory)
encoded, input_name1 = char_replace(input_name) encoded, input_name1 = char_replace(input_name)
except: except Exception:
pass pass
control_value_dict = {"input_directory": text_type(input_directory1)} control_value_dict = {"input_directory": text_type(input_directory1)}
@ -196,7 +196,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
try: try:
core.copy_link(inputFile, target_file, core.USELINK) core.copy_link(inputFile, target_file, core.USELINK)
core.remove_read_only(target_file) core.remove_read_only(target_file)
except: except Exception:
logger.error("Failed to link: {0} to {1}".format(inputFile, target_file)) logger.error("Failed to link: {0} to {1}".format(inputFile, target_file))
input_name, output_destination = convert_to_ascii(input_name, output_destination) input_name, output_destination = convert_to_ascii(input_name, output_destination)
@ -306,7 +306,7 @@ def main(args):
try: try:
input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args) input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args)
except: except Exception:
logger.error("There was a problem loading variables") logger.error("There was a problem loading variables")
return -1 return -1

View file

@ -281,7 +281,7 @@ def initialize(section=None):
# pylint: disable=E1101 # pylint: disable=E1101
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(SYS_ENCODING) sys.setdefaultencoding(SYS_ENCODING)
except: except Exception:
print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable' print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable'
'\nor find another way to force Python to use {codec} for string encoding.'.format '\nor find another way to force Python to use {codec} for string encoding.'.format
(codec=SYS_ENCODING)) (codec=SYS_ENCODING))
@ -345,7 +345,7 @@ def initialize(section=None):
# restart nzbToMedia # restart nzbToMedia
try: try:
del MYAPP del MYAPP
except: except Exception:
pass pass
restart() restart()
else: else:
@ -426,22 +426,22 @@ def initialize(section=None):
try: try:
subprocess.Popen(["nice"], stdout=devnull, stderr=devnull).communicate() subprocess.Popen(["nice"], stdout=devnull, stderr=devnull).communicate()
NICENESS.extend(['nice', '-n{0}'.format(int(CFG["Posix"]["niceness"]))]) NICENESS.extend(['nice', '-n{0}'.format(int(CFG["Posix"]["niceness"]))])
except: except Exception:
pass pass
try: try:
subprocess.Popen(["ionice"], stdout=devnull, stderr=devnull).communicate() subprocess.Popen(["ionice"], stdout=devnull, stderr=devnull).communicate()
try: try:
NICENESS.extend(['ionice', '-c{0}'.format(int(CFG["Posix"]["ionice_class"]))]) NICENESS.extend(['ionice', '-c{0}'.format(int(CFG["Posix"]["ionice_class"]))])
except: except Exception:
pass pass
try: try:
if 'ionice' in NICENESS: if 'ionice' in NICENESS:
NICENESS.extend(['-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))]) NICENESS.extend(['-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))])
else: else:
NICENESS.extend(['ionice', '-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))]) NICENESS.extend(['ionice', '-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))])
except: except Exception:
pass pass
except: except Exception:
pass pass
devnull.close() devnull.close()
@ -480,7 +480,7 @@ def initialize(section=None):
GENERALOPTS.append('+genpts') GENERALOPTS.append('+genpts')
try: try:
OUTPUTQUALITYPERCENT = int(CFG["Transcoder"]["outputQualityPercent"]) OUTPUTQUALITYPERCENT = int(CFG["Transcoder"]["outputQualityPercent"])
except: except Exception:
pass pass
OUTPUTVIDEOPATH = CFG["Transcoder"]["outputVideoPath"] OUTPUTVIDEOPATH = CFG["Transcoder"]["outputVideoPath"]
PROCESSOUTPUT = int(CFG["Transcoder"]["processOutput"]) PROCESSOUTPUT = int(CFG["Transcoder"]["processOutput"])
@ -505,19 +505,19 @@ def initialize(section=None):
VPRESET = CFG["Transcoder"]["outputVideoPreset"].strip() VPRESET = CFG["Transcoder"]["outputVideoPreset"].strip()
try: try:
VFRAMERATE = float(CFG["Transcoder"]["outputVideoFramerate"].strip()) VFRAMERATE = float(CFG["Transcoder"]["outputVideoFramerate"].strip())
except: except Exception:
pass pass
try: try:
VCRF = int(CFG["Transcoder"]["outputVideoCRF"].strip()) VCRF = int(CFG["Transcoder"]["outputVideoCRF"].strip())
except: except Exception:
pass pass
try: try:
VLEVEL = CFG["Transcoder"]["outputVideoLevel"].strip() VLEVEL = CFG["Transcoder"]["outputVideoLevel"].strip()
except: except Exception:
pass pass
try: try:
VBITRATE = int((CFG["Transcoder"]["outputVideoBitrate"].strip()).replace('k', '000')) VBITRATE = int((CFG["Transcoder"]["outputVideoBitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
VRESOLUTION = CFG["Transcoder"]["outputVideoResolution"] VRESOLUTION = CFG["Transcoder"]["outputVideoResolution"]
ACODEC = CFG["Transcoder"]["outputAudioCodec"].strip() ACODEC = CFG["Transcoder"]["outputAudioCodec"].strip()
@ -528,11 +528,11 @@ def initialize(section=None):
ACODEC_ALLOW = [] ACODEC_ALLOW = []
try: try:
ACHANNELS = int(CFG["Transcoder"]["outputAudioChannels"].strip()) ACHANNELS = int(CFG["Transcoder"]["outputAudioChannels"].strip())
except: except Exception:
pass pass
try: try:
ABITRATE = int((CFG["Transcoder"]["outputAudioBitrate"].strip()).replace('k', '000')) ABITRATE = int((CFG["Transcoder"]["outputAudioBitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
ACODEC2 = CFG["Transcoder"]["outputAudioTrack2Codec"].strip() ACODEC2 = CFG["Transcoder"]["outputAudioTrack2Codec"].strip()
ACODEC2_ALLOW = CFG["Transcoder"]["AudioCodec2Allow"].strip() ACODEC2_ALLOW = CFG["Transcoder"]["AudioCodec2Allow"].strip()
@ -542,11 +542,11 @@ def initialize(section=None):
ACODEC2_ALLOW = [] ACODEC2_ALLOW = []
try: try:
ACHANNELS2 = int(CFG["Transcoder"]["outputAudioTrack2Channels"].strip()) ACHANNELS2 = int(CFG["Transcoder"]["outputAudioTrack2Channels"].strip())
except: except Exception:
pass pass
try: try:
ABITRATE2 = int((CFG["Transcoder"]["outputAudioTrack2Bitrate"].strip()).replace('k', '000')) ABITRATE2 = int((CFG["Transcoder"]["outputAudioTrack2Bitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
ACODEC3 = CFG["Transcoder"]["outputAudioOtherCodec"].strip() ACODEC3 = CFG["Transcoder"]["outputAudioOtherCodec"].strip()
ACODEC3_ALLOW = CFG["Transcoder"]["AudioOtherCodecAllow"].strip() ACODEC3_ALLOW = CFG["Transcoder"]["AudioOtherCodecAllow"].strip()
@ -556,11 +556,11 @@ def initialize(section=None):
ACODEC3_ALLOW = [] ACODEC3_ALLOW = []
try: try:
ACHANNELS3 = int(CFG["Transcoder"]["outputAudioOtherChannels"].strip()) ACHANNELS3 = int(CFG["Transcoder"]["outputAudioOtherChannels"].strip())
except: except Exception:
pass pass
try: try:
ABITRATE3 = int((CFG["Transcoder"]["outputAudioOtherBitrate"].strip()).replace('k', '000')) ABITRATE3 = int((CFG["Transcoder"]["outputAudioOtherBitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
SCODEC = CFG["Transcoder"]["outputSubtitleCodec"].strip() SCODEC = CFG["Transcoder"]["outputSubtitleCodec"].strip()
BURN = int(CFG["Transcoder"]["burnInSubtitle"].strip()) BURN = int(CFG["Transcoder"]["burnInSubtitle"].strip())
@ -765,17 +765,17 @@ def initialize(section=None):
else: else:
try: try:
SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip() SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not SEVENZIP: if not SEVENZIP:
try: try:
SEVENZIP = subprocess.Popen(['which', '7zr'], stdout=subprocess.PIPE).communicate()[0].strip() SEVENZIP = subprocess.Popen(['which', '7zr'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not SEVENZIP: if not SEVENZIP:
try: try:
SEVENZIP = subprocess.Popen(['which', '7za'], stdout=subprocess.PIPE).communicate()[0].strip() SEVENZIP = subprocess.Popen(['which', '7za'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not SEVENZIP: if not SEVENZIP:
SEVENZIP = None SEVENZIP = None
@ -783,7 +783,7 @@ def initialize(section=None):
"Failed to locate 7zip. Transcoding of disk images and extraction of .7z files will not be possible!") "Failed to locate 7zip. Transcoding of disk images and extraction of .7z files will not be possible!")
try: try:
PAR2CMD = subprocess.Popen(['which', 'par2'], stdout=subprocess.PIPE).communicate()[0].strip() PAR2CMD = subprocess.Popen(['which', 'par2'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not PAR2CMD: if not PAR2CMD:
PAR2CMD = None PAR2CMD = None
@ -798,12 +798,12 @@ def initialize(section=None):
else: else:
try: try:
FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip() FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFMPEG: if not FFMPEG:
try: try:
FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip() FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFMPEG: if not FFMPEG:
FFMPEG = None FFMPEG = None
@ -819,12 +819,12 @@ def initialize(section=None):
else: else:
try: try:
FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip() FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFPROBE: if not FFPROBE:
try: try:
FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip() FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFPROBE: if not FFPROBE:
FFPROBE = None FFPROBE = None

View file

@ -60,7 +60,7 @@ class Game(object):
logger.postprocess("moving files to library: {0}".format(library), section) logger.postprocess("moving files to library: {0}".format(library), section)
try: try:
shutil.move(dir_name, os.path.join(library, input_name)) shutil.move(dir_name, os.path.join(library, input_name))
except: except Exception:
logger.error("Unable to move {0} to {1}".format(dir_name, os.path.join(library, input_name)), section) logger.error("Unable to move {0} to {1}".format(dir_name, os.path.join(library, input_name)), section)
return [1, "{0}: Failed to post-process - Unable to move files".format(section)] return [1, "{0}: Failed to post-process - Unable to move files".format(section)]
else: else:

View file

@ -75,7 +75,7 @@ class Movie(object):
download_id = release[release_id]['download_info']['id'] download_id = release[release_id]['download_info']['id']
downloader = release[release_id]['download_info']['downloader'] downloader = release[release_id]['download_info']['downloader']
release_status_old = release[release_id]['status'] release_status_old = release[release_id]['status']
except: except Exception:
pass pass
if not os.path.isdir(dir_name) and os.path.isfile(dir_name): # If the input directory is a file, assume single file download and split dir/name. if not os.path.isdir(dir_name) and os.path.isfile(dir_name): # If the input directory is a file, assume single file download and split dir/name.
@ -300,7 +300,7 @@ class Movie(object):
logger.postprocess("SUCCESS: Release for {0} has now been marked with a status of [{1}]".format( logger.postprocess("SUCCESS: Release for {0} has now been marked with a status of [{1}]".format(
title, str(release_status_new).upper()), section) title, str(release_status_new).upper()), section)
return [0, "{0}: Successfully post-processed {1}".format(section, input_name)] return [0, "{0}: Successfully post-processed {1}".format(section, input_name)]
except: except Exception:
pass pass
elif scan_id: elif scan_id:
url = "{0}/{1}".format(base_url, scan_id) url = "{0}/{1}".format(base_url, scan_id)
@ -416,7 +416,7 @@ class Movie(object):
id = result[section]['_id'] id = result[section]['_id']
results[id] = result[section] results[id] = result[section]
return results return results
except: except Exception:
pass pass
# Gather release info and proceed with trying to narrow results to one release choice # Gather release info and proceed with trying to narrow results to one release choice
@ -441,7 +441,7 @@ class Movie(object):
id = release['_id'] id = release['_id']
results[id] = release results[id] = release
results[id]['title'] = movie['title'] results[id]['title'] = movie['title']
except: except Exception:
continue continue
# Narrow results by removing old releases by comparing their last_edit field # Narrow results by removing old releases by comparing their last_edit field
@ -451,7 +451,7 @@ class Movie(object):
try: try:
if x2["last_edit"] > x1["last_edit"]: if x2["last_edit"] > x1["last_edit"]:
results.pop(id1) results.pop(id1)
except: except Exception:
continue continue
# Search downloads on clients for a match to try and narrow our results down to 1 # Search downloads on clients for a match to try and narrow our results down to 1
@ -460,7 +460,7 @@ class Movie(object):
try: try:
if not find_download(str(x['download_info']['downloader']).lower(), x['download_info']['id']): if not find_download(str(x['download_info']['downloader']).lower(), x['download_info']['id']):
results.pop(id) results.pop(id)
except: except Exception:
continue continue
return results return results

View file

@ -18,7 +18,7 @@ class Section(configobj.Section, object):
if not section.sections: if not section.sections:
try: try:
value = list(ConfigObj.find_key(section, 'enabled'))[0] value = list(ConfigObj.find_key(section, 'enabled'))[0]
except: except Exception:
value = 0 value = 0
if int(value) == 1: if int(value) == 1:
return section return section
@ -28,7 +28,7 @@ class Section(configobj.Section, object):
for subsection in subsections: for subsection in subsections:
try: try:
value = list(ConfigObj.find_key(subsections, 'enabled'))[0] value = list(ConfigObj.find_key(subsections, 'enabled'))[0]
except: except Exception:
value = 0 value = 0
if int(value) != 1: if int(value) != 1:
@ -45,7 +45,7 @@ class Section(configobj.Section, object):
for subsection in to_return: for subsection in to_return:
try: try:
value = list(ConfigObj.find_key(to_return[subsection], key))[0] value = list(ConfigObj.find_key(to_return[subsection], key))[0]
except: except Exception:
value = None value = None
if not value: if not value:
@ -198,7 +198,7 @@ class ConfigObj(configobj.ConfigObj, Section):
if not list(ConfigObj.find_key(CFG_NEW, option)): if not list(ConfigObj.find_key(CFG_NEW, option)):
try: try:
values.pop(option) values.pop(option)
except: except Exception:
pass pass
return values return values

View file

@ -147,7 +147,7 @@ def extract(file_path, output_destination):
break break
else: else:
continue continue
except: except Exception:
core.logger.error("EXTRACTOR: Extraction failed for {file}. " core.logger.error("EXTRACTOR: Extraction failed for {file}. "
"Could not call command {cmd}".format "Could not call command {cmd}".format
(file=file_path, cmd=cmd)) (file=file_path, cmd=cmd))
@ -165,13 +165,13 @@ def extract(file_path, output_destination):
if not os.path.join(dir, subdir) in orig_files: if not os.path.join(dir, subdir) in orig_files:
try: try:
os.chmod(os.path.join(dir, subdir), perms) os.chmod(os.path.join(dir, subdir), perms)
except: except Exception:
pass pass
for file in files: for file in files:
if not os.path.join(dir, file) in orig_files: if not os.path.join(dir, file) in orig_files:
try: try:
shutil.copymode(file_path, os.path.join(dir, file)) shutil.copymode(file_path, os.path.join(dir, file))
except: except Exception:
pass pass
return True return True
else: else:

View file

@ -82,7 +82,7 @@ def auto_fork(section, input_category):
optional_parameters = [] optional_parameters = []
try: try:
optional_parameters = r.json()['data']['optionalParameters'].keys() optional_parameters = r.json()['data']['optionalParameters'].keys()
except: except Exception:
optional_parameters = r.json()['data']['data']['optionalParameters'].keys() optional_parameters = r.json()['data']['data']['optionalParameters'].keys()
for param in params: for param in params:
if param not in optional_parameters: if param not in optional_parameters:

View file

@ -177,7 +177,7 @@ def par2(dirname):
proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket) proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket)
proc.communicate() proc.communicate()
result = proc.returncode result = proc.returncode
except: except Exception:
logger.error("par2 file processing for {0} has failed".format(parfile), "PAR2") logger.error("par2 file processing for {0} has failed".format(parfile), "PAR2")
if result == 0: if result == 0:
logger.info("par2 file processing succeeded", "PAR2") logger.info("par2 file processing succeeded", "PAR2")

View file

@ -69,7 +69,7 @@ def zip_out(file, img, bitbucket):
cmd = [core.SEVENZIP, '-so', 'e', img, file] cmd = [core.SEVENZIP, '-so', 'e', img, file]
try: try:
procin = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) procin = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket)
except: except Exception:
logger.error("Extracting [{0}] has failed".format(file), 'TRANSCODER') logger.error("Extracting [{0}] has failed".format(file), 'TRANSCODER')
return procin return procin
@ -99,7 +99,7 @@ def get_video_details(videofile, img=None, bitbucket=None):
out, err = proc.communicate() out, err = proc.communicate()
result = proc.returncode result = proc.returncode
video_details = json.loads(out) video_details = json.loads(out)
except: except Exception:
pass pass
if not video_details: if not video_details:
try: try:
@ -113,7 +113,7 @@ def get_video_details(videofile, img=None, bitbucket=None):
out, err = proc.communicate() out, err = proc.communicate()
result = proc.returncode result = proc.returncode
video_details = json.loads(out) video_details = json.loads(out)
except: except Exception:
logger.error("Checking [{0}] has failed".format(file), 'TRANSCODER') logger.error("Checking [{0}] has failed".format(file), 'TRANSCODER')
return video_details, result return video_details, result
@ -265,23 +265,23 @@ def build_commands(file, new_dir, movie_name, bitbucket):
if "Commentary" in val.get("tags").get("title"): # Split out commentry tracks. if "Commentary" in val.get("tags").get("title"): # Split out commentry tracks.
commentary.append(val) commentary.append(val)
del audio_streams[i] del audio_streams[i]
except: except Exception:
continue continue
try: try:
audio1 = [item for item in audio_streams if item["tags"]["language"] == core.ALANGUAGE] audio1 = [item for item in audio_streams if item["tags"]["language"] == core.ALANGUAGE]
except: # no language tags. Assume only 1 language. except Exception: # no language tags. Assume only 1 language.
audio1 = audio_streams audio1 = audio_streams
try: try:
audio2 = [item for item in audio1 if item["codec_name"] in core.ACODEC_ALLOW] audio2 = [item for item in audio1 if item["codec_name"] in core.ACODEC_ALLOW]
except: except Exception:
audio2 = [] audio2 = []
try: try:
audio3 = [item for item in audio_streams if item["tags"]["language"] != core.ALANGUAGE] audio3 = [item for item in audio_streams if item["tags"]["language"] != core.ALANGUAGE]
except: except Exception:
audio3 = [] audio3 = []
try: try:
audio4 = [item for item in audio3 if item["codec_name"] in core.ACODEC_ALLOW] audio4 = [item for item in audio3 if item["codec_name"] in core.ACODEC_ALLOW]
except: except Exception:
audio4 = [] audio4 = []
if audio2: # right (or only) language and codec... if audio2: # right (or only) language and codec...
@ -328,11 +328,11 @@ def build_commands(file, new_dir, movie_name, bitbucket):
used_audio += 1 used_audio += 1
try: try:
audio5 = [item for item in audio1 if item["codec_name"] in core.ACODEC2_ALLOW] audio5 = [item for item in audio1 if item["codec_name"] in core.ACODEC2_ALLOW]
except: except Exception:
audio5 = [] audio5 = []
try: try:
audio6 = [item for item in audio3 if item["codec_name"] in core.ACODEC2_ALLOW] audio6 = [item for item in audio3 if item["codec_name"] in core.ACODEC2_ALLOW]
except: except Exception:
audio6 = [] audio6 = []
if audio5: # right language and codec. if audio5: # right language and codec.
map_cmd.extend(['-map', '0:{index}'.format(index=audio5[0]["index"])]) map_cmd.extend(['-map', '0:{index}'.format(index=audio5[0]["index"])])
@ -425,7 +425,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
for lan in core.SLANGUAGES: for lan in core.SLANGUAGES:
try: try:
subs1 = [item for item in sub_streams if item["tags"]["language"] == lan] subs1 = [item for item in sub_streams if item["tags"]["language"] == lan]
except: except Exception:
subs1 = [] subs1 = []
if core.BURN and not subs1 and not burnt and os.path.isfile(file): if core.BURN and not subs1 and not burnt and os.path.isfile(file):
for subfile in get_subs(file): for subfile in get_subs(file):
@ -489,7 +489,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
metlan = Language(lan) metlan = Language(lan)
if len(lan) == 2: if len(lan) == 2:
metlan = Language.fromalpha2(lan) metlan = Language.fromalpha2(lan)
except: except Exception:
pass pass
if metlan: if metlan:
meta_cmd.extend(['-metadata:s:s:{x}'.format(x=len(s_mapped) + n), meta_cmd.extend(['-metadata:s:s:{x}'.format(x=len(s_mapped) + n),
@ -544,7 +544,7 @@ def extract_subs(file, newfile_path, bitbucket):
sub_streams = [item for item in video_details["streams"] if sub_streams = [item for item in video_details["streams"] if
item["codec_type"] == "subtitle" and item["tags"]["language"] in core.SLANGUAGES and item[ item["codec_type"] == "subtitle" and item["tags"]["language"] in core.SLANGUAGES and item[
"codec_name"] != "hdmv_pgs_subtitle" and item["codec_name"] != "pgssub"] "codec_name"] != "hdmv_pgs_subtitle" and item["codec_name"] != "pgssub"]
except: except Exception:
sub_streams = [item for item in video_details["streams"] if sub_streams = [item for item in video_details["streams"] if
item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[
"codec_name"] != "pgssub"] "codec_name"] != "pgssub"]
@ -575,13 +575,13 @@ def extract_subs(file, newfile_path, bitbucket):
proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket) proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket)
proc.communicate() proc.communicate()
result = proc.returncode result = proc.returncode
except: except Exception:
logger.error("Extracting subtitle has failed") logger.error("Extracting subtitle has failed")
if result == 0: if result == 0:
try: try:
shutil.copymode(file, output_file) shutil.copymode(file, output_file)
except: except Exception:
pass pass
logger.info("Extracting {0} subtitle from {1} has succeeded".format(lan, file)) logger.info("Extracting {0} subtitle from {1} has succeeded".format(lan, file))
else: else:
@ -605,7 +605,7 @@ def process_list(it, new_dir, bitbucket):
if not vts_path: if not vts_path:
try: try:
vts_path = re.match("(.+VIDEO_TS)", item).groups()[0] vts_path = re.match("(.+VIDEO_TS)", item).groups()[0]
except: except Exception:
vts_path = os.path.split(item)[0] vts_path = os.path.split(item)[0]
rem_list.append(item) rem_list.append(item)
elif re.match(".+VIDEO_TS.", item) or re.match(".+VTS_[0-9][0-9]_[0-9].", item): elif re.match(".+VIDEO_TS.", item) or re.match(".+VTS_[0-9][0-9]_[0-9].", item):
@ -677,7 +677,7 @@ def rip_iso(item, new_dir, bitbucket):
if not new_files: if not new_files:
logger.error("No VIDEO_TS folder found in image file {0}".format(item), "TRANSCODER") logger.error("No VIDEO_TS folder found in image file {0}".format(item), "TRANSCODER")
new_files = [failure_dir] new_files = [failure_dir]
except: except Exception:
logger.error("Failed to extract from image file {0}".format(item), "TRANSCODER") logger.error("Failed to extract from image file {0}".format(item), "TRANSCODER")
new_files = [failure_dir] new_files = [failure_dir]
return new_files return new_files
@ -788,7 +788,7 @@ def transcode_directory(dir_name):
procin.stdout.close() procin.stdout.close()
proc.communicate() proc.communicate()
result = proc.returncode result = proc.returncode
except: except Exception:
logger.error("Transcoding of video {0} has failed".format(newfile_path)) logger.error("Transcoding of video {0} has failed".format(newfile_path))
if core.SUBSDIR and result == 0 and isinstance(file, string_types): if core.SUBSDIR and result == 0 and isinstance(file, string_types):
@ -803,13 +803,13 @@ def transcode_directory(dir_name):
if result == 0: if result == 0:
try: try:
shutil.copymode(file, newfile_path) shutil.copymode(file, newfile_path)
except: except Exception:
pass pass
logger.info("Transcoding of video to {0} succeeded".format(newfile_path)) logger.info("Transcoding of video to {0} succeeded".format(newfile_path))
if os.path.isfile(newfile_path) and (file in new_list or not core.DUPLICATE): if os.path.isfile(newfile_path) and (file in new_list or not core.DUPLICATE):
try: try:
os.unlink(file) os.unlink(file)
except: except Exception:
pass pass
else: else:
logger.error("Transcoding of video to {0} failed with result {1}".format(newfile_path, result)) logger.error("Transcoding of video to {0} failed with result {1}".format(newfile_path, result))
@ -819,7 +819,7 @@ def transcode_directory(dir_name):
for file in rem_list: for file in rem_list:
try: try:
os.unlink(file) os.unlink(file)
except: except Exception:
pass pass
if not os.listdir(text_type(new_dir)): # this is an empty directory and we didn't transcode into it. if not os.listdir(text_type(new_dir)): # this is an empty directory and we didn't transcode into it.
os.rmdir(new_dir) os.rmdir(new_dir)

View file

@ -15,7 +15,7 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
core.USER_SCRIPT_MEDIAEXTENSIONS = settings["user_script_mediaExtensions"].lower() core.USER_SCRIPT_MEDIAEXTENSIONS = settings["user_script_mediaExtensions"].lower()
if isinstance(core.USER_SCRIPT_MEDIAEXTENSIONS, str): if isinstance(core.USER_SCRIPT_MEDIAEXTENSIONS, str):
core.USER_SCRIPT_MEDIAEXTENSIONS = core.USER_SCRIPT_MEDIAEXTENSIONS.split(',') core.USER_SCRIPT_MEDIAEXTENSIONS = core.USER_SCRIPT_MEDIAEXTENSIONS.split(',')
except: except Exception:
core.USER_SCRIPT_MEDIAEXTENSIONS = [] core.USER_SCRIPT_MEDIAEXTENSIONS = []
core.USER_SCRIPT = settings.get("user_script_path") core.USER_SCRIPT = settings.get("user_script_path")
@ -26,13 +26,13 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
core.USER_SCRIPT_PARAM = settings["user_script_param"] core.USER_SCRIPT_PARAM = settings["user_script_param"]
if isinstance(core.USER_SCRIPT_PARAM, str): if isinstance(core.USER_SCRIPT_PARAM, str):
core.USER_SCRIPT_PARAM = core.USER_SCRIPT_PARAM.split(',') core.USER_SCRIPT_PARAM = core.USER_SCRIPT_PARAM.split(',')
except: except Exception:
core.USER_SCRIPT_PARAM = [] core.USER_SCRIPT_PARAM = []
try: try:
core.USER_SCRIPT_SUCCESSCODES = settings["user_script_successCodes"] core.USER_SCRIPT_SUCCESSCODES = settings["user_script_successCodes"]
if isinstance(core.USER_SCRIPT_SUCCESSCODES, str): if isinstance(core.USER_SCRIPT_SUCCESSCODES, str):
core.USER_SCRIPT_SUCCESSCODES = core.USER_SCRIPT_SUCCESSCODES.split(',') core.USER_SCRIPT_SUCCESSCODES = core.USER_SCRIPT_SUCCESSCODES.split(',')
except: except Exception:
core.USER_SCRIPT_SUCCESSCODES = 0 core.USER_SCRIPT_SUCCESSCODES = 0
core.USER_SCRIPT_CLEAN = int(settings.get("user_script_clean", 1)) core.USER_SCRIPT_CLEAN = int(settings.get("user_script_clean", 1))
@ -95,7 +95,7 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
"If the UserScript completed successfully you should add {0} to the user_script_successCodes".format( "If the UserScript completed successfully you should add {0} to the user_script_successCodes".format(
res), "USERSCRIPT") res), "USERSCRIPT")
result = int(1) result = int(1)
except: except Exception:
logger.error("UserScript {0} has failed".format(command[0]), "USERSCRIPT") logger.error("UserScript {0} has failed".format(command[0]), "USERSCRIPT")
result = int(1) result = int(1)
final_result += result final_result += result

View file

@ -90,7 +90,7 @@ def sanitize_name(name):
name = name.strip(' .') name = name.strip(' .')
try: try:
name = name.encode(core.SYS_ENCODING) name = name.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
return name return name
@ -128,11 +128,11 @@ def category_search(input_directory, input_name, input_category, root, categorie
try: try:
input_name = input_name.encode(core.SYS_ENCODING) input_name = input_name.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
try: try:
input_directory = input_directory.encode(core.SYS_ENCODING) input_directory = input_directory.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
if input_directory is None: # =Nothing to process here. if input_directory is None: # =Nothing to process here.
@ -233,7 +233,7 @@ def is_min_size(input_name, min_size):
if file_ext in core.AUDIOCONTAINER: if file_ext in core.AUDIOCONTAINER:
try: try:
input_size = get_dir_size(os.path.dirname(input_name)) input_size = get_dir_size(os.path.dirname(input_name))
except: except Exception:
logger.error("Failed to get file size for {0}".format(input_name), 'MINSIZE') logger.error("Failed to get file size for {0}".format(input_name), 'MINSIZE')
return True return True
@ -335,7 +335,7 @@ def flatten(output_destination):
try: try:
shutil.move(outputFile, target) shutil.move(outputFile, target)
except: except Exception:
logger.error("Could not flatten {0}".format(outputFile), 'FLATTEN') logger.error("Could not flatten {0}".format(outputFile), 'FLATTEN')
remove_empty_folders(output_destination) # Cleanup empty directories remove_empty_folders(output_destination) # Cleanup empty directories
@ -372,7 +372,7 @@ def remove_read_only(filename):
(name=filename)) (name=filename))
try: try:
os.chmod(filename, stat.S_IWRITE) os.chmod(filename, stat.S_IWRITE)
except: except Exception:
logger.warning('Cannot change permissions of {file}'.format(file=filename), logger.WARNING) logger.warning('Cannot change permissions of {file}'.format(file=filename), logger.WARNING)
@ -403,7 +403,7 @@ def test_connection(host, port):
try: try:
socket.create_connection((host, port)) socket.create_connection((host, port))
return "Up" return "Up"
except: except Exception:
return "Down" return "Down"
@ -515,19 +515,19 @@ def parse_rtorrent(args):
input_directory = os.path.normpath(args[1]) input_directory = os.path.normpath(args[1])
try: try:
input_name = args[2] input_name = args[2]
except: except Exception:
input_name = '' input_name = ''
try: try:
input_category = args[3] input_category = args[3]
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = args[4] input_hash = args[4]
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = args[4] input_id = args[4]
except: except Exception:
input_id = '' input_id = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -539,15 +539,15 @@ def parse_utorrent(args):
input_name = args[2] input_name = args[2]
try: try:
input_category = args[3] input_category = args[3]
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = args[4] input_hash = args[4]
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = args[4] input_id = args[4]
except: except Exception:
input_id = '' input_id = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -561,7 +561,7 @@ def parse_deluge(args):
input_id = args[1] input_id = args[1]
try: try:
input_category = core.TORRENT_CLASS.core.get_torrent_status(input_id, ['label']).get()['label'] input_category = core.TORRENT_CLASS.core.get_torrent_status(input_id, ['label']).get()['label']
except: except Exception:
input_category = '' input_category = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -580,32 +580,32 @@ def parse_vuze(args):
# vuze usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D%N%L%I%K%F" # vuze usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D%N%L%I%K%F"
try: try:
input = args[1].split(',') input = args[1].split(',')
except: except Exception:
input = [] input = []
try: try:
input_directory = os.path.normpath(input[0]) input_directory = os.path.normpath(input[0])
except: except Exception:
input_directory = '' input_directory = ''
try: try:
input_name = input[1] input_name = input[1]
except: except Exception:
input_name = '' input_name = ''
try: try:
input_category = input[2] input_category = input[2]
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = input[3] input_hash = input[3]
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = input[3] input_id = input[3]
except: except Exception:
input_id = '' input_id = ''
try: try:
if input[4] == 'single': if input[4] == 'single':
input_name = input[5] input_name = input[5]
except: except Exception:
pass pass
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -615,27 +615,27 @@ def parse_qbittorrent(args):
# qbittorrent usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D|%N|%L|%I" # qbittorrent usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D|%N|%L|%I"
try: try:
input = args[1].split('|') input = args[1].split('|')
except: except Exception:
input = [] input = []
try: try:
input_directory = os.path.normpath(input[0].replace('"', '')) input_directory = os.path.normpath(input[0].replace('"', ''))
except: except Exception:
input_directory = '' input_directory = ''
try: try:
input_name = input[1].replace('"', '') input_name = input[1].replace('"', '')
except: except Exception:
input_name = '' input_name = ''
try: try:
input_category = input[2].replace('"', '') input_category = input[2].replace('"', '')
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = input[3].replace('"', '') input_hash = input[3].replace('"', '')
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = input[3].replace('"', '') input_id = input[3].replace('"', '')
except: except Exception:
input_id = '' input_id = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -654,7 +654,7 @@ def parse_args(client_agent, args):
try: try:
return clients[client_agent](args) return clients[client_agent](args)
except: except Exception:
return None, None, None, None, None return None, None, None, None, None
@ -706,7 +706,7 @@ def get_dirs(section, subsection, link='hard'):
try: try:
new_path = new_path.encode(core.SYS_ENCODING) new_path = new_path.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
# Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe). # Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe).
@ -721,7 +721,7 @@ def get_dirs(section, subsection, link='hard'):
newfile = os.path.join(new_path, sanitize_name(os.path.split(mediafile)[1])) newfile = os.path.join(new_path, sanitize_name(os.path.split(mediafile)[1]))
try: try:
newfile = newfile.encode(core.SYS_ENCODING) newfile = newfile.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
# link file to its new path # link file to its new path
@ -787,7 +787,7 @@ def remove_dir(dir_name):
logger.info("Deleting {0}".format(dir_name)) logger.info("Deleting {0}".format(dir_name))
try: try:
shutil.rmtree(text_type(dir_name), onerror=onerror) shutil.rmtree(text_type(dir_name), onerror=onerror)
except: except Exception:
logger.error("Unable to delete folder {0}".format(dir_name)) logger.error("Unable to delete folder {0}".format(dir_name))
@ -804,7 +804,7 @@ def clean_dir(path, section, subsection):
delete_ignored = int(cfg.get('delete_ignored', 0)) delete_ignored = int(cfg.get('delete_ignored', 0))
try: try:
num_files = len(list_media_files(path, min_size=min_size, delete_ignored=delete_ignored)) num_files = len(list_media_files(path, min_size=min_size, delete_ignored=delete_ignored))
except: except Exception:
num_files = 'unknown' num_files = 'unknown'
if num_files > 0: if num_files > 0:
logger.info( logger.info(
@ -815,7 +815,7 @@ def clean_dir(path, section, subsection):
logger.info("Directory {0} has been processed, removing ...".format(path), 'CLEANDIRS') logger.info("Directory {0} has been processed, removing ...".format(path), 'CLEANDIRS')
try: try:
shutil.rmtree(path, onerror=onerror) shutil.rmtree(path, onerror=onerror)
except: except Exception:
logger.error("Unable to delete directory {0}".format(path)) logger.error("Unable to delete directory {0}".format(path))
@ -827,7 +827,7 @@ def create_torrent_class(client_agent):
try: try:
logger.debug("Connecting to {0}: {1}".format(client_agent, core.UTORRENTWEBUI)) logger.debug("Connecting to {0}: {1}".format(client_agent, core.UTORRENTWEBUI))
tc = UTorrentClient(core.UTORRENTWEBUI, core.UTORRENTUSR, core.UTORRENTPWD) tc = UTorrentClient(core.UTORRENTWEBUI, core.UTORRENTUSR, core.UTORRENTPWD)
except: except Exception:
logger.error("Failed to connect to uTorrent") logger.error("Failed to connect to uTorrent")
if client_agent == 'transmission': if client_agent == 'transmission':
@ -837,7 +837,7 @@ def create_torrent_class(client_agent):
tc = TransmissionClient(core.TRANSMISSIONHOST, core.TRANSMISSIONPORT, tc = TransmissionClient(core.TRANSMISSIONHOST, core.TRANSMISSIONPORT,
core.TRANSMISSIONUSR, core.TRANSMISSIONUSR,
core.TRANSMISSIONPWD) core.TRANSMISSIONPWD)
except: except Exception:
logger.error("Failed to connect to Transmission") logger.error("Failed to connect to Transmission")
if client_agent == 'deluge': if client_agent == 'deluge':
@ -846,7 +846,7 @@ def create_torrent_class(client_agent):
tc = DelugeClient() tc = DelugeClient()
tc.connect(host=core.DELUGEHOST, port=core.DELUGEPORT, username=core.DELUGEUSR, tc.connect(host=core.DELUGEHOST, port=core.DELUGEPORT, username=core.DELUGEUSR,
password=core.DELUGEPWD) password=core.DELUGEPWD)
except: except Exception:
logger.error("Failed to connect to Deluge") logger.error("Failed to connect to Deluge")
if client_agent == 'qbittorrent': if client_agent == 'qbittorrent':
@ -854,7 +854,7 @@ def create_torrent_class(client_agent):
logger.debug("Connecting to {0}: http://{1}:{2}".format(client_agent, core.QBITTORRENTHOST, core.QBITTORRENTPORT)) logger.debug("Connecting to {0}: http://{1}:{2}".format(client_agent, core.QBITTORRENTHOST, core.QBITTORRENTPORT))
tc = qBittorrentClient("http://{0}:{1}/".format(core.QBITTORRENTHOST, core.QBITTORRENTPORT)) tc = qBittorrentClient("http://{0}:{1}/".format(core.QBITTORRENTHOST, core.QBITTORRENTPORT))
tc.login(core.QBITTORRENTUSR, core.QBITTORRENTPWD) tc.login(core.QBITTORRENTUSR, core.QBITTORRENTPWD)
except: except Exception:
logger.error("Failed to connect to qBittorrent") logger.error("Failed to connect to qBittorrent")
return tc return tc
@ -872,7 +872,7 @@ def pause_torrent(client_agent, input_hash, input_id, input_name):
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "": if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "":
core.TORRENT_CLASS.pause(input_hash) core.TORRENT_CLASS.pause(input_hash)
time.sleep(5) time.sleep(5)
except: except Exception:
logger.warning("Failed to stop torrent {0} in {1}".format(input_name, client_agent)) logger.warning("Failed to stop torrent {0} in {1}".format(input_name, client_agent))
@ -890,7 +890,7 @@ def resume_torrent(client_agent, input_hash, input_id, input_name):
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "": if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "":
core.TORRENT_CLASS.resume(input_hash) core.TORRENT_CLASS.resume(input_hash)
time.sleep(5) time.sleep(5)
except: except Exception:
logger.warning("Failed to start torrent {0} in {1}".format(input_name, client_agent)) logger.warning("Failed to start torrent {0} in {1}".format(input_name, client_agent))
@ -908,7 +908,7 @@ def remove_torrent(client_agent, input_hash, input_id, input_name):
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "": if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "":
core.TORRENT_CLASS.delete_permanently(input_hash) core.TORRENT_CLASS.delete_permanently(input_hash)
time.sleep(5) time.sleep(5)
except: except Exception:
logger.warning("Failed to delete torrent {0} in {1}".format(input_name, client_agent)) logger.warning("Failed to delete torrent {0} in {1}".format(input_name, client_agent))
else: else:
resume_torrent(client_agent, input_hash, input_id, input_name) resume_torrent(client_agent, input_hash, input_id, input_name)
@ -981,7 +981,7 @@ def get_nzoid(input_name):
result = r.json() result = r.json()
clean_name = os.path.splitext(os.path.split(input_name)[1])[0] clean_name = os.path.splitext(os.path.split(input_name)[1])[0]
slots.extend([(slot['nzo_id'], slot['filename']) for slot in result['queue']['slots']]) slots.extend([(slot['nzo_id'], slot['filename']) for slot in result['queue']['slots']])
except: except Exception:
logger.warning("Data from SABnzbd queue could not be parsed") logger.warning("Data from SABnzbd queue could not be parsed")
params['mode'] = "history" params['mode'] = "history"
try: try:
@ -993,7 +993,7 @@ def get_nzoid(input_name):
result = r.json() result = r.json()
clean_name = os.path.splitext(os.path.split(input_name)[1])[0] clean_name = os.path.splitext(os.path.split(input_name)[1])[0]
slots.extend([(slot['nzo_id'], slot['name']) for slot in result['history']['slots']]) slots.extend([(slot['nzo_id'], slot['name']) for slot in result['history']['slots']])
except: except Exception:
logger.warning("Data from SABnzbd history could not be parsed") logger.warning("Data from SABnzbd history could not be parsed")
try: try:
for nzo_id, name in slots: for nzo_id, name in slots:
@ -1001,7 +1001,7 @@ def get_nzoid(input_name):
nzoid = nzo_id nzoid = nzo_id
logger.debug("Found nzoid: {0}".format(nzoid)) logger.debug("Found nzoid: {0}".format(nzoid))
break break
except: except Exception:
logger.warning("Data from SABnzbd could not be parsed") logger.warning("Data from SABnzbd could not be parsed")
return nzoid return nzoid
@ -1039,7 +1039,7 @@ def is_media_file(mediafile, media=True, audio=True, meta=True, archives=True, o
# ignore MAC OS's "resource fork" files # ignore MAC OS's "resource fork" files
if file_name.startswith('._'): if file_name.startswith('._'):
return False return False
except: except Exception:
pass pass
if (media and file_ext.lower() in core.MEDIACONTAINER) \ if (media and file_ext.lower() in core.MEDIACONTAINER) \
or (audio and file_ext.lower() in core.AUDIOCONTAINER) \ or (audio and file_ext.lower() in core.AUDIOCONTAINER) \
@ -1064,7 +1064,7 @@ def list_media_files(path, min_size=0, delete_ignored=0, media=True, audio=True,
os.unlink(path) os.unlink(path)
logger.debug('Ignored file {0} has been removed ...'.format logger.debug('Ignored file {0} has been removed ...'.format
(cur_file)) (cur_file))
except: except Exception:
pass pass
else: else:
files.append(path) files.append(path)
@ -1086,7 +1086,7 @@ def list_media_files(path, min_size=0, delete_ignored=0, media=True, audio=True,
os.unlink(full_cur_file) os.unlink(full_cur_file)
logger.debug('Ignored file {0} has been removed ...'.format logger.debug('Ignored file {0} has been removed ...'.format
(cur_file)) (cur_file))
except: except Exception:
pass pass
continue continue
@ -1126,7 +1126,7 @@ def find_imdbid(dir_name, input_name, omdb_api_key):
logger.info('Searching IMDB for imdbID ...') logger.info('Searching IMDB for imdbID ...')
try: try:
guess = guessit.guessit(input_name) guess = guessit.guessit(input_name)
except: except Exception:
guess = None guess = None
if guess: if guess:
# Movie Title # Movie Title
@ -1156,12 +1156,12 @@ def find_imdbid(dir_name, input_name, omdb_api_key):
try: try:
results = r.json() results = r.json()
except: except Exception:
logger.error("No json data returned from omdbapi.com") logger.error("No json data returned from omdbapi.com")
try: try:
imdbid = results['imdbID'] imdbid = results['imdbID']
except: except Exception:
logger.error("No imdbID returned from omdbapi.com") logger.error("No imdbID returned from omdbapi.com")
if imdbid: if imdbid:
@ -1214,14 +1214,14 @@ def import_subs(filename):
return return
try: try:
subliminal.region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'}) subliminal.region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'})
except: except Exception:
pass pass
languages = set() languages = set()
for item in core.SLANGUAGES: for item in core.SLANGUAGES:
try: try:
languages.add(Language(item)) languages.add(Language(item))
except: except Exception:
pass pass
if not languages: if not languages:
return return
@ -1361,7 +1361,7 @@ class PosixProcess(object):
# Make sure it is not a "stale" pidFile # Make sure it is not a "stale" pidFile
try: try:
pid = int(open(self.pidpath, 'r').read().strip()) pid = int(open(self.pidpath, 'r').read().strip())
except: except Exception:
pid = None pid = None
# Check list of running pids, if not running it is stale so overwrite # Check list of running pids, if not running it is stale so overwrite
if isinstance(pid, int): if isinstance(pid, int):
@ -1381,7 +1381,7 @@ class PosixProcess(object):
fp = open(self.pidpath, 'w') fp = open(self.pidpath, 'w')
fp.write(str(os.getpid())) fp.write(str(os.getpid()))
fp.close() fp.close()
except: except Exception:
pass pass
return self.lasterror return self.lasterror

View file

@ -285,7 +285,7 @@ class GitUpdateManager(UpdateManager):
self._num_commits_behind = int(output.count("<")) self._num_commits_behind = int(output.count("<"))
self._num_commits_ahead = int(output.count(">")) self._num_commits_ahead = int(output.count(">"))
except: except Exception:
logger.log(u"git didn't return numbers for behind and ahead, not using it", logger.DEBUG) logger.log(u"git didn't return numbers for behind and ahead, not using it", logger.DEBUG)
return return

View file

@ -664,7 +664,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
try: try:
encoded, input_directory1 = char_replace(input_directory) encoded, input_directory1 = char_replace(input_directory)
encoded, input_name1 = char_replace(input_name) encoded, input_name1 = char_replace(input_name)
except: except Exception:
pass pass
control_value_dict = {"input_directory": text_type(input_directory1)} control_value_dict = {"input_directory": text_type(input_directory1)}
@ -716,7 +716,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
logger.error('Remote Path is enabled for {0}:{1} but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!'.format( logger.error('Remote Path is enabled for {0}:{1} but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!'.format(
section_name, input_category)) section_name, input_category))
return [-1, ""] return [-1, ""]
except: except Exception:
logger.error('Remote Path {0} is not valid for {1}:{2} Please set this to either 0 to disable or 1 to enable!'.format( logger.error('Remote Path {0} is not valid for {1}:{2} Please set this to either 0 to disable or 1 to enable!'.format(
core.get("remote_path"), section_name, input_category)) core.get("remote_path"), section_name, input_category))