]> git.phdru.name Git - bookmarks_db.git/blobdiff - check_url.py
Fix(Py3): Fix `check_url.py`
[bookmarks_db.git] / check_url.py
index 46135c53e6877a3e186c8a48f7ab4a6f764ed963..bb13be23a59bead68130405ffd224b12225c14e2 100755 (executable)
@@ -1,31 +1,35 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 """Robot interface - check URLs from the command line
 
 This file is a part of Bookmarks database and Internet robot.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2010-2017 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2010-2023 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 import sys
-import httplib
 
-HTTP = httplib.HTTP
+from bkmk_objects import Bookmark
+from Writers.bkmk_wflad import strftime
 
-class MyHTTP(HTTP):
-    def _setup(self, conn):
-        HTTP._setup(self, conn)
-        self.set_debuglevel(1)
+try:
+    import httplib
+except ImportError:
+    pass
+else:
+    HTTP = httplib.HTTP
 
-httplib.HTTP = MyHTTP
+    class MyHTTP(HTTP):
+        def _setup(self, conn):
+            HTTP._setup(self, conn)
+            self.set_debuglevel(1)
 
-from bkmk_objects import Bookmark
-from Writers.bkmk_wflad import strftime
+    httplib.HTTP = MyHTTP
 
 
 def run():
-    print("Broytman check_url, Copyright (C) 2010-2017 PhiloSoft Design")
+    print("Broytman check_url, Copyright (C) 2010-2023 PhiloSoft Design")
 
     if len(sys.argv) < 2:
         sys.stderr.write("Usage: check_url.py url1 [url2...]\n")
@@ -54,7 +58,10 @@ def run():
   LastModified: %s
   IconURI: %s
   Icon: %s
-  """ % (bookmark.href, getattr(bookmark, 'real_title', ''), strftime(bookmark.last_modified), bookmark.icon_href, bookmark.icon))
+  """ % (
+              bookmark.href, getattr(bookmark, 'real_title', ''),
+              strftime(bookmark.last_modified), bookmark.icon_href,
+              bookmark.icon))
 
     robot.stop()
     log.close()