logs display
This commit is contained in:
@@ -72,5 +72,5 @@ class Gallery:
|
|||||||
LOG.debug(command)
|
LOG.debug(command)
|
||||||
self.command = command
|
self.command = command
|
||||||
|
|
||||||
def run_command(self, verbose: bool, on_line=None):
|
def run_command(self, verbose: bool, on_line=None, log_failure: bool = True):
|
||||||
run(self.command, verbose, on_line=on_line)
|
run(self.command, verbose, on_line=on_line, log_failure=log_failure)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ def parse_gallery(gdl_list: str, user: User) -> None:
|
|||||||
|
|
||||||
gallery.generate_command(user)
|
gallery.generate_command(user)
|
||||||
handler = _make_gallery_error_handler(link)
|
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]:
|
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:
|
def handle(line: str) -> None:
|
||||||
if "[error]" in line:
|
if "[error]" in line:
|
||||||
reason = line.split("[error]", 1)[1].strip()
|
reason = line.split("[error]", 1)[1].strip()
|
||||||
|
LOG.warning("Error for %s: %s", link, reason)
|
||||||
if reason in REVISION_ERRORS:
|
if reason in REVISION_ERRORS:
|
||||||
with db.connect() as conn:
|
with db.connect() as conn:
|
||||||
db.mark_requires_revision_by_norm(conn, norm, reason)
|
db.mark_requires_revision_by_norm(conn, norm, reason)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
LOG.warning("Marked requires_revision for %s", link)
|
||||||
if any(tok in reason for tok in TRANSIENT_ERRORS):
|
if any(tok in reason for tok in TRANSIENT_ERRORS):
|
||||||
LOG.warning("Transient error for %s: %s", link, reason)
|
LOG.warning("Transient error for %s: %s", link, reason)
|
||||||
return
|
return
|
||||||
@@ -134,6 +136,7 @@ def _make_gallery_error_handler(link: str):
|
|||||||
with db.connect() as conn:
|
with db.connect() as conn:
|
||||||
db.mark_requires_revision_by_norm(conn, norm, "No results for")
|
db.mark_requires_revision_by_norm(conn, norm, "No results for")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
LOG.warning("Marked requires_revision for %s", link)
|
||||||
return
|
return
|
||||||
|
|
||||||
return handle
|
return handle
|
||||||
@@ -167,7 +170,7 @@ def _handle_gallery_link(user: User, link: str, args, conn) -> None:
|
|||||||
gallery.opt_args = parse_instagram(link)
|
gallery.opt_args = parse_instagram(link)
|
||||||
gallery.generate_command(user)
|
gallery.generate_command(user)
|
||||||
handler = _make_gallery_error_handler(link)
|
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:
|
def _handle_comic_link(link: str, args) -> None:
|
||||||
@@ -177,7 +180,7 @@ def _handle_comic_link(link: str, args) -> None:
|
|||||||
gallery.link = link
|
gallery.link = link
|
||||||
gallery.generate_command(is_comic=True)
|
gallery.generate_command(is_comic=True)
|
||||||
handler = _make_gallery_error_handler(link)
|
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)
|
save_comic(link)
|
||||||
|
|
||||||
|
|
||||||
@@ -199,7 +202,7 @@ def _handle_other_link(user: User, link: str, args) -> None:
|
|||||||
gallery.dest = "push"
|
gallery.dest = "push"
|
||||||
gallery.generate_command(user)
|
gallery.generate_command(user)
|
||||||
handler = _make_gallery_error_handler(link)
|
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):
|
def video_command(video: Video):
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ def run(
|
|||||||
cwd: Path | None = None,
|
cwd: Path | None = None,
|
||||||
check: bool = False,
|
check: bool = False,
|
||||||
on_line=None,
|
on_line=None,
|
||||||
|
log_failure: bool = True,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run command in a subprocess"""
|
"""Run command in a subprocess"""
|
||||||
# pylint: disable=subprocess-run-check
|
# pylint: disable=subprocess-run-check
|
||||||
@@ -86,7 +87,7 @@ def run(
|
|||||||
|
|
||||||
if on_line is None:
|
if on_line is None:
|
||||||
result = subprocess.run(args, check=check, cwd=cwd)
|
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)
|
LOG.warning("Command failed (%s): %s", result.returncode, args)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ def run(
|
|||||||
returncode = proc.wait()
|
returncode = proc.wait()
|
||||||
if check and returncode != 0:
|
if check and returncode != 0:
|
||||||
raise subprocess.CalledProcessError(returncode, args)
|
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)
|
LOG.warning("Command failed (%s): %s", returncode, args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user