]> git.phdru.name Git - bookmarks_db.git/blobdiff - check_url.py
Build(Makefile): Update the list of example shell scripts
[bookmarks_db.git] / check_url.py
index 0d40ba9672e9c01a986c2cfcf0f9ce7bffb4a0d8..bb13be23a59bead68130405ffd224b12225c14e2 100755 (executable)
@@ -1,4 +1,4 @@
-#! /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.
@@ -9,21 +9,23 @@ __copyright__ = "Copyright (C) 2010-2023 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 import sys
-import httplib
 
-HTTP = httplib.HTTP
-
-
-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
 
+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():
@@ -56,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()