1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 12:12:34 +01:00

directly pass exception instances as 'exc_info' logger argument

This commit is contained in:
Mike Fährmann 2024-09-19 14:50:08 +02:00
parent dd56bb2187
commit a051e1c955
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
6 changed files with 18 additions and 15 deletions

View File

@ -45,7 +45,7 @@ class YoutubeDLDownloader(DownloaderBase):
except (ImportError, SyntaxError) as exc: except (ImportError, SyntaxError) as exc:
self.log.error("Cannot import module '%s'", self.log.error("Cannot import module '%s'",
getattr(exc, "name", "")) getattr(exc, "name", ""))
self.log.debug("", exc_info=True) self.log.debug("", exc_info=exc)
self.download = lambda u, p: False self.download = lambda u, p: False
return False return False
self.ytdl_instance = ytdl_instance = ytdl.construct_YoutubeDL( self.ytdl_instance = ytdl_instance = ytdl.construct_YoutubeDL(
@ -64,8 +64,8 @@ class YoutubeDLDownloader(DownloaderBase):
if not info_dict: if not info_dict:
try: try:
info_dict = ytdl_instance.extract_info(url[5:], download=False) info_dict = ytdl_instance.extract_info(url[5:], download=False)
except Exception: except Exception as exc:
pass self.log.debug("", exc_info=exc)
if not info_dict: if not info_dict:
return False return False
@ -120,8 +120,8 @@ class YoutubeDLDownloader(DownloaderBase):
self.out.start(pathfmt.path) self.out.start(pathfmt.path)
try: try:
ytdl_instance.process_info(info_dict) ytdl_instance.process_info(info_dict)
except Exception: except Exception as exc:
self.log.debug("Traceback", exc_info=True) self.log.debug("", exc_info=exc)
return False return False
return True return True

View File

@ -79,7 +79,7 @@ class _8chanThreadExtractor(_8chanExtractor):
self.cookies = self.cookies_prepare() self.cookies = self.cookies_prepare()
except Exception as exc: except Exception as exc:
self.log.debug("Failed to fetch captcha cookies: %s: %s", self.log.debug("Failed to fetch captcha cookies: %s: %s",
exc.__class__.__name__, exc, exc_info=True) exc.__class__.__name__, exc, exc_info=exc)
# download files # download files
posts = thread.pop("posts", ()) posts = thread.pop("posts", ())

View File

@ -37,11 +37,13 @@ class FlickrExtractor(Extractor):
extract = self.api._extract_format extract = self.api._extract_format
for photo in self.photos(): for photo in self.photos():
try: try:
1/0
photo = extract(photo) photo = extract(photo)
except Exception as exc: except Exception as exc:
self.log.warning( self.log.warning(
"Skipping %s (%s)", photo["id"], exc.__class__.__name__) "Skipping photo %s (%s: %s)",
self.log.debug("", exc_info=True) photo["id"], exc.__class__.__name__, exc)
self.log.debug("", exc_info=exc)
else: else:
photo.update(data) photo.update(data)
url = photo["url"] url = photo["url"]

View File

@ -53,8 +53,8 @@ class NewgroundsExtractor(Extractor):
try: try:
post = self.extract_post(post_url) post = self.extract_post(post_url)
url = post.get("url") url = post.get("url")
except Exception: except Exception as exc:
self.log.debug("", exc_info=True) self.log.debug("", exc_info=exc)
url = None url = None
if url: if url:

View File

@ -158,12 +158,12 @@ class Job():
raise raise
except exception.GalleryDLException as exc: except exception.GalleryDLException as exc:
log.error("%s: %s", exc.__class__.__name__, exc) log.error("%s: %s", exc.__class__.__name__, exc)
log.debug("", exc_info=True) log.debug("", exc_info=exc)
self.status |= exc.code self.status |= exc.code
except OSError as exc: except OSError as exc:
log.error("Unable to download data: %s: %s", log.error("Unable to download data: %s: %s",
exc.__class__.__name__, exc) exc.__class__.__name__, exc)
log.debug("", exc_info=True) log.debug("", exc_info=exc)
self.status |= 128 self.status |= 128
except Exception as exc: except Exception as exc:
log.error(("An unexpected error occurred: %s - %s. " log.error(("An unexpected error occurred: %s - %s. "
@ -171,7 +171,7 @@ class Job():
"copy its output and report this issue on " "copy its output and report this issue on "
"https://github.com/mikf/gallery-dl/issues ."), "https://github.com/mikf/gallery-dl/issues ."),
exc.__class__.__name__, exc) exc.__class__.__name__, exc)
log.debug("", exc_info=True) log.debug("", exc_info=exc)
self.status |= 1 self.status |= 1
except BaseException: except BaseException:
self.status |= 1 self.status |= 1
@ -642,7 +642,7 @@ class DownloadJob(Job):
except Exception as exc: except Exception as exc:
pp_log.error("'%s' initialization failed: %s: %s", pp_log.error("'%s' initialization failed: %s: %s",
name, exc.__class__.__name__, exc) name, exc.__class__.__name__, exc)
pp_log.debug("", exc_info=True) pp_log.debug("", exc_info=exc)
else: else:
pp_list.append(pp_obj) pp_list.append(pp_obj)

View File

@ -223,11 +223,12 @@ class UgoiraPP(PostProcessor):
print() print()
self.log.error("Unable to invoke FFmpeg (%s: %s)", self.log.error("Unable to invoke FFmpeg (%s: %s)",
exc.__class__.__name__, exc) exc.__class__.__name__, exc)
self.log.debug("", exc_info=exc)
pathfmt.realpath = pathfmt.temppath pathfmt.realpath = pathfmt.temppath
except Exception as exc: except Exception as exc:
print() print()
self.log.error("%s: %s", exc.__class__.__name__, exc) self.log.error("%s: %s", exc.__class__.__name__, exc)
self.log.debug("", exc_info=True) self.log.debug("", exc_info=exc)
pathfmt.realpath = pathfmt.temppath pathfmt.realpath = pathfmt.temppath
else: else:
if self.mtime: if self.mtime: