X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Robots%2Fbkmk_rforking_sub.py;h=8bbf68f57028b7c2bfc80c68407ab3d94a9afbe5;hb=011586eca56d3bde3fef2087579e6cbc0682f5b4;hp=e392080697344298d388c72cfeb005bc20c63e0a;hpb=c9cfb54ef36e77aee7187e4533f063d407073ad8;p=bookmarks_db.git diff --git a/Robots/bkmk_rforking_sub.py b/Robots/bkmk_rforking_sub.py index e392080..8bbf68f 100755 --- a/Robots/bkmk_rforking_sub.py +++ b/Robots/bkmk_rforking_sub.py @@ -1,52 +1,51 @@ -#! /usr/bin/env python -"""Check URL - subprocess for the forking robot +#! /usr/bin/env python3 +"""Subprocess for the forking robot - check URL using bkmk_rurlib robot This file is a part of Bookmarks database and Internet robot. + """ -__version__ = "$Revision$"[11:-2] -__revision__ = "$Id$"[5:-2] -__date__ = "$Date$"[7:-2] __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 1999-2011 PhiloSoft Design" +__copyright__ = "Copyright (C) 1999-2023 PhiloSoft Design" __license__ = "GNU GPL" __all__ = [] -import sys, os - -lib_dir = os.path.normpath(os.path.dirname(sys.argv[0]) + os.sep + os.pardir) -sys.path.append(lib_dir) # for bkmk_objects.py +import os +import sys try: - import cPickle - pickle = cPickle + import cPickle + pickle = cPickle except ImportError: - import pickle + import pickle + +lib_dir = os.path.normpath(os.path.dirname(os.path.dirname(sys.argv[0]))) +sys.path.append(lib_dir) # for bkmk_objects.py -from subproc import RecordFile -import bkmk_rsimple +from subproc import RecordFile # noqa: E402 import not at top of file def run(): - bkmk_in = RecordFile(sys.stdin) - bkmk_out = RecordFile(sys.stdout) + bkmk_in = RecordFile(getattr(sys.stdin, 'buffer', None) or sys.stdin) + bkmk_out = RecordFile(getattr(sys.stdout, 'buffer', None) or sys.stdout) - from m_lib.flog import openlog - log = openlog("check2.log") - from bkmk_rsimple import robot_simple - robot = robot_simple(log) + from m_lib.flog import openlog + log = openlog("check2.log") + log.outfile.reconfigure(encoding='utf-8') + from robots import robot + robot = robot(log) - while 1: - bookmark = pickle.loads(bkmk_in.read_record()) - log(bookmark.href) - robot.check_url(bookmark) - bkmk_out.write_record(pickle.dumps(bookmark)) - log.outfile.flush() + while 1: + bookmark = pickle.loads(bkmk_in.read_record()) + log(bookmark.href) + robot.check_url(bookmark) + bkmk_out.write_record(pickle.dumps(bookmark)) + log.outfile.flush() - log.close() + log.close() if __name__ == '__main__': - run() + run()