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