diff --git a/src/download/classes/gallery.py b/src/download/classes/gallery.py index 7b7894b..46d76dc 100644 --- a/src/download/classes/gallery.py +++ b/src/download/classes/gallery.py @@ -72,5 +72,5 @@ class Gallery: LOG.debug(command) self.command = command - def run_command(self, verbose: bool, on_line=None): - run(self.command, verbose, on_line=on_line) + def run_command(self, verbose: bool, on_line=None, log_failure: bool = True): + run(self.command, verbose, on_line=on_line, log_failure=log_failure) diff --git a/src/download/download.py b/src/download/download.py index 137cf24..19ef605 100644 --- a/src/download/download.py +++ b/src/download/download.py @@ -86,7 +86,7 @@ def parse_gallery(gdl_list: str, user: User) -> None: gallery.generate_command(user) handler = _make_gallery_error_handler(link) - gallery.run_command(args.flag_verbose, on_line=handler) + gallery.run_command(args.flag_verbose, on_line=handler, log_failure=False) def parse_instagram(link: str, post_type: list[str] | str | None = None) -> list[str]: @@ -123,10 +123,12 @@ def _make_gallery_error_handler(link: str): def handle(line: str) -> None: if "[error]" in line: reason = line.split("[error]", 1)[1].strip() + LOG.warning("Error for %s: %s", link, reason) if reason in REVISION_ERRORS: with db.connect() as conn: db.mark_requires_revision_by_norm(conn, norm, reason) conn.commit() + LOG.warning("Marked requires_revision for %s", link) if any(tok in reason for tok in TRANSIENT_ERRORS): LOG.warning("Transient error for %s: %s", link, reason) return @@ -134,6 +136,7 @@ def _make_gallery_error_handler(link: str): with db.connect() as conn: db.mark_requires_revision_by_norm(conn, norm, "No results for") conn.commit() + LOG.warning("Marked requires_revision for %s", link) return return handle @@ -167,7 +170,7 @@ def _handle_gallery_link(user: User, link: str, args, conn) -> None: gallery.opt_args = parse_instagram(link) gallery.generate_command(user) handler = _make_gallery_error_handler(link) - gallery.run_command(args.flag_verbose, on_line=handler) + gallery.run_command(args.flag_verbose, on_line=handler, log_failure=False) def _handle_comic_link(link: str, args) -> None: @@ -177,7 +180,7 @@ def _handle_comic_link(link: str, args) -> None: gallery.link = link gallery.generate_command(is_comic=True) handler = _make_gallery_error_handler(link) - gallery.run_command(args.flag_verbose, on_line=handler) + gallery.run_command(args.flag_verbose, on_line=handler, log_failure=False) save_comic(link) @@ -199,7 +202,7 @@ def _handle_other_link(user: User, link: str, args) -> None: gallery.dest = "push" gallery.generate_command(user) handler = _make_gallery_error_handler(link) - gallery.run_command(args.flag_verbose, on_line=handler) + gallery.run_command(args.flag_verbose, on_line=handler, log_failure=False) def video_command(video: Video): diff --git a/src/download/functions.py b/src/download/functions.py index b1959c6..33c0b74 100644 --- a/src/download/functions.py +++ b/src/download/functions.py @@ -67,6 +67,7 @@ def run( cwd: Path | None = None, check: bool = False, on_line=None, + log_failure: bool = True, ) -> None: """Run command in a subprocess""" # pylint: disable=subprocess-run-check @@ -86,7 +87,7 @@ def run( if on_line is None: result = subprocess.run(args, check=check, cwd=cwd) - if not check and result.returncode != 0: + if log_failure and not check and result.returncode != 0: LOG.warning("Command failed (%s): %s", result.returncode, args) return @@ -104,7 +105,7 @@ def run( returncode = proc.wait() if check and returncode != 0: raise subprocess.CalledProcessError(returncode, args) - if not check and returncode != 0: + if log_failure and not check and returncode != 0: LOG.warning("Command failed (%s): %s", returncode, args)