]> git.phdru.name Git - bookmarks_db.git/blob - Robots/bkmk_rforking_sub.py
Robots no longer have one global temporary file - there are at least two
[bookmarks_db.git] / Robots / bkmk_rforking_sub.py
1 #! /usr/bin/env python
2 """
3    Check URL - subprocess for the forking robot
4
5    Written by Broytman. Copyright (C) 1999-2010 PhiloSoft Design.
6 """
7
8
9 import sys, os
10
11 lib_dir = os.path.normpath(os.path.dirname(sys.argv[0]) + os.sep + os.pardir)
12 sys.path.append(lib_dir) # for bkmk_objects.py
13
14 try:
15    import cPickle
16    pickle = cPickle
17 except ImportError:
18    import pickle
19
20 from subproc import RecordFile
21 import bkmk_rsimple
22
23
24 def run():
25    bkmk_in = RecordFile(sys.stdin)
26    bkmk_out = RecordFile(sys.stdout)
27
28    from m_lib.flog import openlog
29    log = openlog("check2.log")
30    from bkmk_rsimple import robot_simple
31    robot = robot_simple(log)
32
33    while 1:
34       bookmark = pickle.loads(bkmk_in.read_record())
35       log(bookmark.href)
36       robot.check_url(bookmark)
37       bkmk_out.write_record(pickle.dumps(bookmark))
38       log.outfile.flush()
39
40    log.close()
41
42
43 if __name__ == '__main__':
44    run()