]> git.evergreen-ils.org Git - working/random.git/blob - contrib/evergreen/eg_bib_search.py
fixed bug in property reading from eg_data module. more python style tweaks
[working/random.git] / contrib / evergreen / eg_bib_search.py
1 from constrictor.task import Task
2 from constrictor.script import Script, ScriptManager, ScriptThread
3 from constrictor.log import *
4 import eg_utils, eg_data, eg_tasks
5 import random
6
7 class BibSearchScript(Script):
8
9     def run(self):
10
11         dm = eg_data.DataManager()
12         org_id = dm.get_thread_data(eg_data.PROP_ORG_ID) or 1
13
14         search_args = {
15             'org_unit' : org_id,
16             'depth' : 0,
17             # randomly add many more optional flags
18         }
19
20         search_term = eg_utils.random_phrase(None, 3) # search phrase has 1-3 words
21         log_info('Search term="%s" args="%s"' % (search_term, str(search_args)))
22             
23         res = eg_tasks.BibSearchTask().start(
24             search_args = search_args, 
25             search_term = search_term
26         )
27
28         log_info('Search returned %d hits' % int(res['count']))
29         return True
30
31 eg_utils.init()
32 words_file = open('/usr/share/dict/words') # add config property
33 words = words_file.readlines()
34 words_file.close()
35 ScriptManager.go(BibSearchScript())
36
37
38