]> git.phdru.name Git - bookmarks_db.git/commitdiff
Feat(Robots): Stop the robot ASAP
authorOleg Broytman <phd@phdru.name>
Wed, 7 Aug 2024 17:00:53 +0000 (20:00 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 7 Aug 2024 17:00:53 +0000 (20:00 +0300)
Process bookmarks after the robot stopped. In the future
there will be robots that check multiple URLs in parallel
so bookmarks cannot be processed inside check loop
but can be queried after.

check_urls.py
check_urls_db.py
get_url.py

index e7d68f9246b3afe2e81059b4134025661a449ad0..103553ae36068385ee721f9739cb88c5c112d6a1 100755 (executable)
@@ -44,12 +44,18 @@ def run():
     print("Using", robot)
     robot = robot(log)
 
+    bookmarks = []
     for url in sys.argv[1:]:
         bookmark = Bookmark(href=url, add_date=None)
         bookmark.parent = None
+        bookmarks.append(bookmark)
 
         robot.check_bookmark(bookmark)
 
+    robot.stop()
+    log.close()
+
+    for bookmark in bookmarks:
         if hasattr(bookmark, 'error'):
             print(bookmark.error)
 
@@ -76,9 +82,6 @@ def run():
               )
             )
 
-    robot.stop()
-    log.close()
-
 
 if __name__ == '__main__':
     run()
index 515bbfc3c034126e9c12fd68a24392695f84232a..53827f33538a5ba64a8c0cd5bcc642b727c22483 100755 (executable)
@@ -137,12 +137,16 @@ def run():
 
                 checked[href] = object_no
                 urls_no = urls_no + 1
-                try:
-                    size = size + int(object.size)
-                except (AttributeError, TypeError, ValueError):
-                    pass  # Some object does not have a size :(
     robot.stop()
 
+    for object_no in range(objects):
+        object = root_folder.linear[object_no]
+        if object.isBookmark:
+            try:
+                size = size + int(object.size)
+            except (AttributeError, TypeError, ValueError):
+                pass  # Some object does not have a size :(
+
     if show_pbar:
         del pbar
 
index 2a411e5da119360b8bfeba49e77b4c2d5cb25565..86a58f62089915f013deae2a4ac7af86540ea0be 100755 (executable)
@@ -33,6 +33,7 @@ def run():
 
     error, redirect_code, redirect_to, headers, content = \
         robot.get_url(bookmark, url, True)
+    robot.stop()
 
     if error:
         sys.stderr.write(error + '\n')
@@ -53,8 +54,6 @@ def run():
         else:
             print(content)
 
-    robot.stop()
-
 
 if __name__ == '__main__':
     run()