]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(bkmk_robot_base): Redraw progress bar after unhandled exception
authorOleg Broytman <phd@phdru.name>
Fri, 16 Aug 2024 14:05:48 +0000 (17:05 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 16 Aug 2024 16:21:31 +0000 (19:21 +0300)
Robots/bkmk_robot_base.py
bkmk_objects.py
check_urls_db.py

index 4ccd0935d46b3be309e97f598713cf4e10fd68c1..a504e47ae9503d1b56f83884d1165d5ab71947a1 100644 (file)
@@ -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)
index 6f0663d3554599f769976284c4208c1a00ef0c47..3b604e1fcbc9c82972ab7fbcabb38b497f7dc3d1 100644 (file)
@@ -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
index 64e1805384eb9c44916b4cf97578c913d99d1721..5324a47fc71e124f7cd5b2ea5db2951a871d4dba 100755 (executable)
@@ -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 <phd@phdru.name>"
@@ -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: