mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 23:26:53 +01:00
Don't use bare 'except:'
They catch any exception, including KeyboardInterrupt, we don't want to catch it.
This commit is contained in:
parent
af14000215
commit
70a1165b32
@ -28,7 +28,7 @@
|
|||||||
if METHOD == 'EURISTIC':
|
if METHOD == 'EURISTIC':
|
||||||
try:
|
try:
|
||||||
webpage = compat_urllib_request.urlopen(test['url'], timeout=10).read()
|
webpage = compat_urllib_request.urlopen(test['url'], timeout=10).read()
|
||||||
except:
|
except Exception:
|
||||||
print('\nFail: {0}'.format(test['name']))
|
print('\nFail: {0}'.format(test['name']))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1701,10 +1701,10 @@ def print_debug_header(self):
|
|||||||
out = out.decode().strip()
|
out = out.decode().strip()
|
||||||
if re.match('[0-9a-f]+', out):
|
if re.match('[0-9a-f]+', out):
|
||||||
self._write_string('[debug] Git HEAD: ' + out + '\n')
|
self._write_string('[debug] Git HEAD: ' + out + '\n')
|
||||||
except:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
sys.exc_clear()
|
sys.exc_clear()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self._write_string('[debug] Python version %s - %s\n' % (
|
self._write_string('[debug] Python version %s - %s\n' % (
|
||||||
platform.python_version(), platform_name()))
|
platform.python_version(), platform_name()))
|
||||||
|
@ -389,7 +389,7 @@ def compat_get_terminal_size():
|
|||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = sp.communicate()
|
out, err = sp.communicate()
|
||||||
lines, columns = map(int, out.split())
|
lines, columns = map(int, out.split())
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return _terminal_size(columns, lines)
|
return _terminal_size(columns, lines)
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ def try_utime(self, filename, last_modified_hdr):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
os.utime(filename, (time.time(), filetime))
|
os.utime(filename, (time.time(), filetime))
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return filetime
|
return filetime
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ def _real_extract(self, url):
|
|||||||
webpage, 'JSON parameters')
|
webpage, 'JSON parameters')
|
||||||
try:
|
try:
|
||||||
params = json.loads(json_params)
|
params = json.loads(json_params)
|
||||||
except:
|
except ValueError:
|
||||||
raise ExtractorError('Invalid JSON')
|
raise ExtractorError('Invalid JSON')
|
||||||
|
|
||||||
self.report_extraction(video_id)
|
self.report_extraction(video_id)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@ -269,19 +268,17 @@ def run(self, information):
|
|||||||
else:
|
else:
|
||||||
self._downloader.to_screen('[' + self.basename + '] Destination: ' + new_path)
|
self._downloader.to_screen('[' + self.basename + '] Destination: ' + new_path)
|
||||||
self.run_ffmpeg(path, new_path, acodec, more_opts)
|
self.run_ffmpeg(path, new_path, acodec, more_opts)
|
||||||
except:
|
except AudioConversionError as e:
|
||||||
etype, e, tb = sys.exc_info()
|
raise PostProcessingError(
|
||||||
if isinstance(e, AudioConversionError):
|
'audio conversion failed: ' + e.msg)
|
||||||
msg = 'audio conversion failed: ' + e.msg
|
except Exception:
|
||||||
else:
|
raise PostProcessingError('error running ' + self.basename)
|
||||||
msg = 'error running ' + self.basename
|
|
||||||
raise PostProcessingError(msg)
|
|
||||||
|
|
||||||
# Try to update the date time for extracted audio file.
|
# Try to update the date time for extracted audio file.
|
||||||
if information.get('filetime') is not None:
|
if information.get('filetime') is not None:
|
||||||
try:
|
try:
|
||||||
os.utime(encodeFilename(new_path), (time.time(), information['filetime']))
|
os.utime(encodeFilename(new_path), (time.time(), information['filetime']))
|
||||||
except:
|
except Exception:
|
||||||
self._downloader.report_warning('Cannot update utime of audio file')
|
self._downloader.report_warning('Cannot update utime of audio file')
|
||||||
|
|
||||||
information['filepath'] = new_path
|
information['filepath'] = new_path
|
||||||
|
@ -65,7 +65,7 @@ def update_self(to_screen, verbose):
|
|||||||
# Check if there is a new version
|
# Check if there is a new version
|
||||||
try:
|
try:
|
||||||
newversion = opener.open(VERSION_URL).read().decode('utf-8').strip()
|
newversion = opener.open(VERSION_URL).read().decode('utf-8').strip()
|
||||||
except:
|
except Exception:
|
||||||
if verbose:
|
if verbose:
|
||||||
to_screen(compat_str(traceback.format_exc()))
|
to_screen(compat_str(traceback.format_exc()))
|
||||||
to_screen('ERROR: can\'t find the current version. Please try again later.')
|
to_screen('ERROR: can\'t find the current version. Please try again later.')
|
||||||
@ -78,7 +78,7 @@ def update_self(to_screen, verbose):
|
|||||||
try:
|
try:
|
||||||
versions_info = opener.open(JSON_URL).read().decode('utf-8')
|
versions_info = opener.open(JSON_URL).read().decode('utf-8')
|
||||||
versions_info = json.loads(versions_info)
|
versions_info = json.loads(versions_info)
|
||||||
except:
|
except Exception:
|
||||||
if verbose:
|
if verbose:
|
||||||
to_screen(compat_str(traceback.format_exc()))
|
to_screen(compat_str(traceback.format_exc()))
|
||||||
to_screen('ERROR: can\'t obtain versions info. Please try again later.')
|
to_screen('ERROR: can\'t obtain versions info. Please try again later.')
|
||||||
|
@ -75,7 +75,7 @@ def preferredencoding():
|
|||||||
try:
|
try:
|
||||||
pref = locale.getpreferredencoding()
|
pref = locale.getpreferredencoding()
|
||||||
'TEST'.encode(pref)
|
'TEST'.encode(pref)
|
||||||
except:
|
except Exception:
|
||||||
pref = 'UTF-8'
|
pref = 'UTF-8'
|
||||||
|
|
||||||
return pref
|
return pref
|
||||||
@ -127,7 +127,7 @@ def write_json_file(obj, fn):
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
os.rename(tf.name, fn)
|
os.rename(tf.name, fn)
|
||||||
except:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
os.remove(tf.name)
|
os.remove(tf.name)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
Loading…
Reference in New Issue
Block a user