From a051e1c955ff619ead50681adb0fe6ca93c16b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 19 Sep 2024 14:50:08 +0200 Subject: [PATCH] directly pass exception instances as 'exc_info' logger argument --- gallery_dl/downloader/ytdl.py | 10 +++++----- gallery_dl/extractor/8chan.py | 2 +- gallery_dl/extractor/flickr.py | 6 ++++-- gallery_dl/extractor/newgrounds.py | 4 ++-- gallery_dl/job.py | 8 ++++---- gallery_dl/postprocessor/ugoira.py | 3 ++- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py index b3bec210..950a72f6 100644 --- a/gallery_dl/downloader/ytdl.py +++ b/gallery_dl/downloader/ytdl.py @@ -45,7 +45,7 @@ class YoutubeDLDownloader(DownloaderBase): except (ImportError, SyntaxError) as exc: self.log.error("Cannot import module '%s'", getattr(exc, "name", "")) - self.log.debug("", exc_info=True) + self.log.debug("", exc_info=exc) self.download = lambda u, p: False return False self.ytdl_instance = ytdl_instance = ytdl.construct_YoutubeDL( @@ -64,8 +64,8 @@ class YoutubeDLDownloader(DownloaderBase): if not info_dict: try: info_dict = ytdl_instance.extract_info(url[5:], download=False) - except Exception: - pass + except Exception as exc: + self.log.debug("", exc_info=exc) if not info_dict: return False @@ -120,8 +120,8 @@ class YoutubeDLDownloader(DownloaderBase): self.out.start(pathfmt.path) try: ytdl_instance.process_info(info_dict) - except Exception: - self.log.debug("Traceback", exc_info=True) + except Exception as exc: + self.log.debug("", exc_info=exc) return False return True diff --git a/gallery_dl/extractor/8chan.py b/gallery_dl/extractor/8chan.py index a5e8b273..51163326 100644 --- a/gallery_dl/extractor/8chan.py +++ b/gallery_dl/extractor/8chan.py @@ -79,7 +79,7 @@ class _8chanThreadExtractor(_8chanExtractor): self.cookies = self.cookies_prepare() except Exception as exc: 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 posts = thread.pop("posts", ()) diff --git a/gallery_dl/extractor/flickr.py b/gallery_dl/extractor/flickr.py index 1b4971c3..6aefa11d 100644 --- a/gallery_dl/extractor/flickr.py +++ b/gallery_dl/extractor/flickr.py @@ -37,11 +37,13 @@ class FlickrExtractor(Extractor): extract = self.api._extract_format for photo in self.photos(): try: + 1/0 photo = extract(photo) except Exception as exc: self.log.warning( - "Skipping %s (%s)", photo["id"], exc.__class__.__name__) - self.log.debug("", exc_info=True) + "Skipping photo %s (%s: %s)", + photo["id"], exc.__class__.__name__, exc) + self.log.debug("", exc_info=exc) else: photo.update(data) url = photo["url"] diff --git a/gallery_dl/extractor/newgrounds.py b/gallery_dl/extractor/newgrounds.py index 5fc0ce50..dfa1f6ef 100644 --- a/gallery_dl/extractor/newgrounds.py +++ b/gallery_dl/extractor/newgrounds.py @@ -53,8 +53,8 @@ class NewgroundsExtractor(Extractor): try: post = self.extract_post(post_url) url = post.get("url") - except Exception: - self.log.debug("", exc_info=True) + except Exception as exc: + self.log.debug("", exc_info=exc) url = None if url: diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 2cb8dc5e..4affd550 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -158,12 +158,12 @@ class Job(): raise except exception.GalleryDLException as exc: log.error("%s: %s", exc.__class__.__name__, exc) - log.debug("", exc_info=True) + log.debug("", exc_info=exc) self.status |= exc.code except OSError as exc: log.error("Unable to download data: %s: %s", exc.__class__.__name__, exc) - log.debug("", exc_info=True) + log.debug("", exc_info=exc) self.status |= 128 except Exception as exc: log.error(("An unexpected error occurred: %s - %s. " @@ -171,7 +171,7 @@ class Job(): "copy its output and report this issue on " "https://github.com/mikf/gallery-dl/issues ."), exc.__class__.__name__, exc) - log.debug("", exc_info=True) + log.debug("", exc_info=exc) self.status |= 1 except BaseException: self.status |= 1 @@ -642,7 +642,7 @@ class DownloadJob(Job): except Exception as exc: pp_log.error("'%s' initialization failed: %s: %s", name, exc.__class__.__name__, exc) - pp_log.debug("", exc_info=True) + pp_log.debug("", exc_info=exc) else: pp_list.append(pp_obj) diff --git a/gallery_dl/postprocessor/ugoira.py b/gallery_dl/postprocessor/ugoira.py index 10d5f36a..87a0ba61 100644 --- a/gallery_dl/postprocessor/ugoira.py +++ b/gallery_dl/postprocessor/ugoira.py @@ -223,11 +223,12 @@ class UgoiraPP(PostProcessor): print() self.log.error("Unable to invoke FFmpeg (%s: %s)", exc.__class__.__name__, exc) + self.log.debug("", exc_info=exc) pathfmt.realpath = pathfmt.temppath except Exception as exc: print() 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 else: if self.mtime: