Rename error_to_str to error_to_compat_str
This commit is contained in:
parent
d890b4cc0a
commit
9b9c5355e4
|
@ -49,7 +49,7 @@ from .utils import (
|
||||||
DownloadError,
|
DownloadError,
|
||||||
encode_compat_str,
|
encode_compat_str,
|
||||||
encodeFilename,
|
encodeFilename,
|
||||||
error_to_str,
|
error_to_compat_str,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
format_bytes,
|
format_bytes,
|
||||||
formatSeconds,
|
formatSeconds,
|
||||||
|
@ -683,7 +683,7 @@ class YoutubeDL(object):
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.params.get('ignoreerrors', False):
|
if self.params.get('ignoreerrors', False):
|
||||||
self.report_error(error_to_str(e), tb=encode_compat_str(traceback.format_exc()))
|
self.report_error(error_to_compat_str(e), tb=encode_compat_str(traceback.format_exc()))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
@ -1461,7 +1461,7 @@ class YoutubeDL(object):
|
||||||
if dn and not os.path.exists(dn):
|
if dn and not os.path.exists(dn):
|
||||||
os.makedirs(dn)
|
os.makedirs(dn)
|
||||||
except (OSError, IOError) as err:
|
except (OSError, IOError) as err:
|
||||||
self.report_error('unable to create directory ' + error_to_str(err))
|
self.report_error('unable to create directory ' + error_to_compat_str(err))
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.params.get('writedescription', False):
|
if self.params.get('writedescription', False):
|
||||||
|
@ -1512,7 +1512,7 @@ class YoutubeDL(object):
|
||||||
sub_info['url'], info_dict['id'], note=False)
|
sub_info['url'], info_dict['id'], note=False)
|
||||||
except ExtractorError as err:
|
except ExtractorError as err:
|
||||||
self.report_warning('Unable to download subtitle for "%s": %s' %
|
self.report_warning('Unable to download subtitle for "%s": %s' %
|
||||||
(sub_lang, error_to_str(err.cause)))
|
(sub_lang, error_to_compat_str(err.cause)))
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
sub_filename = subtitles_filename(filename, sub_lang, sub_format)
|
sub_filename = subtitles_filename(filename, sub_lang, sub_format)
|
||||||
|
@ -2041,4 +2041,4 @@ class YoutubeDL(object):
|
||||||
(info_dict['extractor'], info_dict['id'], thumb_display_id, thumb_filename))
|
(info_dict['extractor'], info_dict['id'], thumb_display_id, thumb_filename))
|
||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
self.report_warning('Unable to download thumbnail "%s": %s' %
|
self.report_warning('Unable to download thumbnail "%s": %s' %
|
||||||
(t['url'], error_to_str(err)))
|
(t['url'], error_to_compat_str(err)))
|
||||||
|
|
|
@ -7,7 +7,7 @@ import time
|
||||||
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
encodeFilename,
|
encodeFilename,
|
||||||
error_to_str,
|
error_to_compat_str,
|
||||||
decodeArgument,
|
decodeArgument,
|
||||||
format_bytes,
|
format_bytes,
|
||||||
timeconvert,
|
timeconvert,
|
||||||
|
@ -186,7 +186,7 @@ class FileDownloader(object):
|
||||||
return
|
return
|
||||||
os.rename(encodeFilename(old_filename), encodeFilename(new_filename))
|
os.rename(encodeFilename(old_filename), encodeFilename(new_filename))
|
||||||
except (IOError, OSError) as err:
|
except (IOError, OSError) as err:
|
||||||
self.report_error('unable to rename file: %s' % error_to_str(err))
|
self.report_error('unable to rename file: %s' % error_to_compat_str(err))
|
||||||
|
|
||||||
def try_utime(self, filename, last_modified_hdr):
|
def try_utime(self, filename, last_modified_hdr):
|
||||||
"""Try to set the last-modified time of the given file."""
|
"""Try to set the last-modified time of the given file."""
|
||||||
|
|
|
@ -30,7 +30,7 @@ from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
compiled_regex_type,
|
compiled_regex_type,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
error_to_str,
|
error_to_compat_str,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
fix_xml_ampersands,
|
fix_xml_ampersands,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
|
@ -334,7 +334,7 @@ class InfoExtractor(object):
|
||||||
if errnote is None:
|
if errnote is None:
|
||||||
errnote = 'Unable to download webpage'
|
errnote = 'Unable to download webpage'
|
||||||
|
|
||||||
errmsg = '%s: %s' % (errnote, error_to_str(err))
|
errmsg = '%s: %s' % (errnote, error_to_compat_str(err))
|
||||||
if fatal:
|
if fatal:
|
||||||
raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
|
raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
|
||||||
else:
|
else:
|
||||||
|
@ -624,7 +624,7 @@ class InfoExtractor(object):
|
||||||
else:
|
else:
|
||||||
raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE)
|
raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE)
|
||||||
except (IOError, netrc.NetrcParseError) as err:
|
except (IOError, netrc.NetrcParseError) as err:
|
||||||
self._downloader.report_warning('parsing .netrc: %s' % error_to_str(err))
|
self._downloader.report_warning('parsing .netrc: %s' % error_to_compat_str(err))
|
||||||
|
|
||||||
return (username, password)
|
return (username, password)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from .common import InfoExtractor
|
||||||
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
error_to_str,
|
error_to_compat_str,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
|
@ -278,7 +278,7 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
|
||||||
'https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id,
|
'https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id,
|
||||||
video_id, note=False)
|
video_id, note=False)
|
||||||
except ExtractorError as err:
|
except ExtractorError as err:
|
||||||
self._downloader.report_warning('unable to download video subtitles: %s' % error_to_str(err))
|
self._downloader.report_warning('unable to download video subtitles: %s' % error_to_compat_str(err))
|
||||||
return {}
|
return {}
|
||||||
info = json.loads(sub_list)
|
info = json.loads(sub_list)
|
||||||
if (info['total'] > 0):
|
if (info['total'] > 0):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from ..compat import (
|
||||||
compat_urllib_parse_unquote,
|
compat_urllib_parse_unquote,
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
error_to_str,
|
error_to_compat_str,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
limit_length,
|
limit_length,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
|
@ -116,7 +116,7 @@ class FacebookIE(InfoExtractor):
|
||||||
if re.search(r'id="checkpointSubmitButton"', check_response) is not None:
|
if re.search(r'id="checkpointSubmitButton"', check_response) is not None:
|
||||||
self._downloader.report_warning('Unable to confirm login, you have to login in your brower and authorize the login.')
|
self._downloader.report_warning('Unable to confirm login, you have to login in your brower and authorize the login.')
|
||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
self._downloader.report_warning('unable to log in: %s' % error_to_str(err))
|
self._downloader.report_warning('unable to log in: %s' % error_to_compat_str(err))
|
||||||
return
|
return
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
|
|
|
@ -26,7 +26,7 @@ from ..compat import (
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
encode_dict,
|
encode_dict,
|
||||||
error_to_str,
|
error_to_compat_str,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
get_element_by_attribute,
|
get_element_by_attribute,
|
||||||
|
@ -904,7 +904,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
'https://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id,
|
'https://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id,
|
||||||
video_id, note=False)
|
video_id, note=False)
|
||||||
except ExtractorError as err:
|
except ExtractorError as err:
|
||||||
self._downloader.report_warning('unable to download video subtitles: %s' % error_to_str(err))
|
self._downloader.report_warning('unable to download video subtitles: %s' % error_to_compat_str(err))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
sub_lang_list = {}
|
sub_lang_list = {}
|
||||||
|
|
|
@ -1810,7 +1810,7 @@ def args_to_str(args):
|
||||||
return ' '.join(shlex_quote(a) for a in args)
|
return ' '.join(shlex_quote(a) for a in args)
|
||||||
|
|
||||||
|
|
||||||
def error_to_str(err):
|
def error_to_compat_str(err):
|
||||||
err_str = str(err)
|
err_str = str(err)
|
||||||
# On python 2 error byte string must be decoded with proper
|
# On python 2 error byte string must be decoded with proper
|
||||||
# encoding rather than ascii
|
# encoding rather than ascii
|
||||||
|
|
Loading…
Reference in New Issue