From: Oleg Broytman Date: Fri, 16 Aug 2024 14:05:48 +0000 (+0300) Subject: Fix(bkmk_robot_base): Redraw progress bar after unhandled exception X-Git-Tag: 5.7.0~2 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=f1be2e0d01a5f877ace1baa3b4cef6957516fcbd;p=bookmarks_db.git Fix(bkmk_robot_base): Redraw progress bar after unhandled exception --- diff --git a/Robots/bkmk_robot_base.py b/Robots/bkmk_robot_base.py index 4ccd093..a504e47 100644 --- a/Robots/bkmk_robot_base.py +++ b/Robots/bkmk_robot_base.py @@ -22,6 +22,7 @@ from m_lib.net.www.util import parse_time from bkmk_objects import __version__, Robot from parse_html import parse_html +import bkmk_objects # Fake headers to pretend this is a real browser @@ -325,10 +326,15 @@ class robot_base(Robot): self.log(bookmark.error) except: + tty_pbar = bkmk_objects.tty_pbar + if tty_pbar: + tty_pbar.erase() import traceback traceback.print_exc() bookmark.error = "Exception!" self.log(' Exception: %s' % bookmark.error) + if tty_pbar: + tty_pbar.redraw() finally: self.finish_check_url(bookmark) diff --git a/bkmk_objects.py b/bkmk_objects.py index 6f0663d..3b604e1 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -247,3 +247,7 @@ def set_params(obj, params): params = params.items() for key, value in params: setattr(obj, key, value) + + +# Global var to use in robots +tty_pbar = None diff --git a/check_urls_db.py b/check_urls_db.py index 64e1805..5324a47 100755 --- a/check_urls_db.py +++ b/check_urls_db.py @@ -5,7 +5,6 @@ This file is a part of Bookmarks database and Internet robot. """ from __future__ import print_function -import sys __author__ = "Oleg Broytman " @@ -13,6 +12,9 @@ __copyright__ = "Copyright (C) 2000-2024 PhiloSoft Design" __license__ = "GNU GPL" +import sys + +import bkmk_objects from bkmk_objects import copy_bkmk @@ -95,7 +97,7 @@ def run(): sys.stdout.flush() if show_pbar: - pbar = ttyProgressBar(0, objects) + bkmk_objects.tty_pbar = pbar = ttyProgressBar(0, objects) urls_no = 0 object_count = 0 @@ -144,6 +146,7 @@ def run(): pass # Some object does not have a size :( if show_pbar: + bkmk_objects.tty_pbar = None del pbar if report_stats: