]> git.phdru.name Git - bookmarks_db.git/blob - Robots/bkmk_rforking_sub.py
Feat: Set shebang to `python3`
[bookmarks_db.git] / Robots / bkmk_rforking_sub.py
1 #! /usr/bin/env python3
2 """Subprocess for the forking robot - check URL using bkmk_rurlib robot
3
4 This file is a part of Bookmarks database and Internet robot.
5
6 """
7
8 __author__ = "Oleg Broytman <phd@phdru.name>"
9 __copyright__ = "Copyright (C) 1999-2023 PhiloSoft Design"
10 __license__ = "GNU GPL"
11
12 __all__ = []
13
14
15 import os
16 import sys
17
18 try:
19     import cPickle
20     pickle = cPickle
21 except ImportError:
22     import pickle
23
24 from subproc import RecordFile
25
26 lib_dir = os.path.normpath(os.path.dirname(os.path.dirname(sys.argv[0])))
27 sys.path.append(lib_dir)  # for bkmk_objects.py
28
29
30 def run():
31     bkmk_in = RecordFile(sys.stdin)
32     bkmk_out = RecordFile(sys.stdout)
33
34     from m_lib.flog import openlog
35     log = openlog("check2.log")
36     from robots import robot
37     robot = robot(log)
38
39     while 1:
40         bookmark = pickle.loads(bkmk_in.read_record())
41         log(bookmark.href)
42         robot.check_url(bookmark)
43         bkmk_out.write_record(pickle.dumps(bookmark))
44         log.outfile.flush()
45
46     log.close()
47
48
49 if __name__ == '__main__':
50     run()