]> git.phdru.name Git - bookmarks_db.git/blob - Robots/bkmk_rforking_sub.py
Cleanup code: use 4 spaces
[bookmarks_db.git] / Robots / bkmk_rforking_sub.py
1 #! /usr/bin/env python
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-2017 PhiloSoft Design"
10 __license__ = "GNU GPL"
11
12 __all__ = []
13
14
15 import sys, os
16
17 lib_dir = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir))
18 sys.path.append(lib_dir) # for bkmk_objects.py
19
20 try:
21     import cPickle
22     pickle = cPickle
23 except ImportError:
24     import pickle
25
26 from subproc import RecordFile
27
28
29 def run():
30     bkmk_in = RecordFile(sys.stdin)
31     bkmk_out = RecordFile(sys.stdout)
32
33     from m_lib.flog import openlog
34     log = openlog("check2.log")
35     from robots import robot
36     robot = robot(log)
37
38     while 1:
39         bookmark = pickle.loads(bkmk_in.read_record())
40         log(bookmark.href)
41         robot.check_url(bookmark)
42         bkmk_out.write_record(pickle.dumps(bookmark))
43         log.outfile.flush()
44
45     log.close()
46
47
48 if __name__ == '__main__':
49     run()