|
|
@ -116,6 +116,8 @@ def displayCapabilities(supported_engines): |
|
|
|
def run_search(engine_list): |
|
|
|
def run_search(engine_list): |
|
|
|
""" Run search in engine |
|
|
|
""" Run search in engine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param engine_list List with engine, query and category |
|
|
|
|
|
|
|
|
|
|
|
@retval False if any exceptions occured |
|
|
|
@retval False if any exceptions occured |
|
|
|
@retval True otherwise |
|
|
|
@retval True otherwise |
|
|
|
""" |
|
|
|
""" |
|
|
@ -128,6 +130,7 @@ def run_search(engine_list): |
|
|
|
engine.search(what, cat) |
|
|
|
engine.search(what, cat) |
|
|
|
else: |
|
|
|
else: |
|
|
|
engine.search(what) |
|
|
|
engine.search(what) |
|
|
|
|
|
|
|
|
|
|
|
return True |
|
|
|
return True |
|
|
|
except: |
|
|
|
except: |
|
|
|
return False |
|
|
|
return False |
|
|
@ -147,6 +150,7 @@ def main(args): |
|
|
|
raise SystemExit("./nova2.py [all|engine1[,engine2]*] <category> <keywords>\n" |
|
|
|
raise SystemExit("./nova2.py [all|engine1[,engine2]*] <category> <keywords>\n" |
|
|
|
"available engines: %s" % (','.join(supported_engines))) |
|
|
|
"available engines: %s" % (','.join(supported_engines))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#get only unique engines with set |
|
|
|
engines_list = set(e.lower() for e in args[0].strip().split(',')) |
|
|
|
engines_list = set(e.lower() for e in args[0].strip().split(',')) |
|
|
|
|
|
|
|
|
|
|
|
if 'all' in engines_list: |
|
|
|
if 'all' in engines_list: |
|
|
@ -166,12 +170,13 @@ def main(args): |
|
|
|
raise SystemExit(" - ".join(('Invalid category', cat))) |
|
|
|
raise SystemExit(" - ".join(('Invalid category', cat))) |
|
|
|
|
|
|
|
|
|
|
|
what = urllib.parse.quote(' '.join(args[2:])) |
|
|
|
what = urllib.parse.quote(' '.join(args[2:])) |
|
|
|
|
|
|
|
|
|
|
|
if THREADED: |
|
|
|
if THREADED: |
|
|
|
|
|
|
|
#child process spawning is controlled min(number of searches, number of cpu) |
|
|
|
with Pool(min(len(engines_list), cpu_count())) as pool: |
|
|
|
with Pool(min(len(engines_list), cpu_count())) as pool: |
|
|
|
pool.map(run_search, ([globals()[engine], what, cat] for engine in engines_list)) |
|
|
|
pool.map(run_search, ([globals()[engine], what, cat] for engine in engines_list)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
_ = [run_search([globals()[engine], what, cat]) for engine in engines_list] |
|
|
|
#py3 note: map is needed to be evaluated for content to be executed |
|
|
|
|
|
|
|
all(map(run_search, ([globals()[engine], what, cat] for engine in engines_list))) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
main(argv[1:]) |
|
|
|
main(argv[1:]) |
|
|
|