]> git.phdru.name Git - bookmarks_db.git/blobdiff - check_url.py
Fix(Robots/bkmk_rrequests): Add forgotten spaces in log
[bookmarks_db.git] / check_url.py
index ecaa2fb26582f1daf12209b803fc64dca3b19bbf..a43d00765372b5e13f6e220546d91f55a0f2e4df 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
 
 from bkmk_objects import Bookmark
 from Writers.bkmk_wflad import strftime
 
-HTTP = httplib.HTTP
+try:
+    import httplib
+except ImportError:
+    pass
+else:
+    HTTP = httplib.HTTP
 
+    class MyHTTP(HTTP):
+        def _setup(self, conn):
+            HTTP._setup(self, conn)
+            self.set_debuglevel(1)
 
-class MyHTTP(HTTP):
-    def _setup(self, conn):
-        HTTP._setup(self, conn)
-        self.set_debuglevel(1)
-
-
-httplib.HTTP = MyHTTP
+    httplib.HTTP = MyHTTP
 
 
 def run():
@@ -35,6 +37,8 @@ def run():
 
     from m_lib.flog import makelog
     log = makelog("check.log")
+    log.outfile.reconfigure(encoding='utf-8')
+    sys.stdout.reconfigure(encoding='utf-8')
 
     from robots import robot
     robot = robot(log)
@@ -51,15 +55,26 @@ def run():
 
         else:
             print("""\
-  URL: %s
   Title: %s
+  URL: %s
   LastModified: %s
+  Moved: %s
+  Size: %s
+  Md5: %s
   IconURI: %s
   Icon: %s
+  Charset: %s
   """ % (
-              bookmark.href, getattr(bookmark, 'real_title', ''),
-              strftime(bookmark.last_modified), bookmark.icon_href,
-              bookmark.icon))
+              getattr(bookmark, 'real_title', None)
+              or getattr(bookmark, 'title', None),
+              bookmark.href,
+              strftime(bookmark.last_modified),
+              getattr(bookmark, 'moved', None),
+              getattr(bookmark, 'size', None),
+              getattr(bookmark, 'md5', None),
+              bookmark.icon_href, bookmark.icon, bookmark.charset,
+              )
+            )
 
     robot.stop()
     log.close()