#!/usr/local/bin/python # import sys, os import IDLInterchange import ilu try: dllib = None import dlcoslib except ImportError: import dllib dlcoslib = dllib argc = len(sys.argv) if argc < 2: print 'usage:', sys.argv[0], '' sys.exit(1) if not dllib: wc = dlcoslib.LookupObject(IDLInterchange.CConstrainCollection, "Services/WebCrawler") else: wc = ilu.ObjectOfSBH(IDLInterchange.CConstrainCollection, "1@Service@sunrpc_2_0x31000400_4272011225|tcp_localhost_3000") if wc.IluPing() == 0: print "Service not available." sys.exit(1) query = {} query["aQuery"] = None query["aQueryComponents"] = [sys.argv[1]] ##query["aItemPropertyNames"] = [IDLInterchange.kDocTitle] query["aItemPropertyNames"] = [] query["aMoreSummary"] = [] servpref = {} servpref["aServicePreferences"] = None servpref["aNumberOfItems"] = 10 servpref["aMoreSummary"] = [] results, size, cookie = wc.Constrain(query, servpref) print "submitted query." anItemsNames = results['aState']['aNames'] anItemsState = results['aState']['anItemsState'] aACs = results['aACs'] i=0 for r in anItemsState: j = 0 for p in r: print aACs[i] print anItemsNames[j] + ": " + `dlcoslib.InputAny(p)` j = j + 1 i = i + 1 print `size` print `cookie` ## -------------------------------------------------- aRS = cookie[0]['aTarget'] aCookie = cookie[0]['aCookie'] results, cookie = aRS.GetItems([IDLInterchange.kDocTitle], aCookie, 10) anItemsNames = results['aState']['aNames'] anItemsState = results['aState']['anItemsState'] for r in anItemsState: i = 0 for p in r: print anItemsNames[i] + ": " + `dlcoslib.InputAny(p)` i = i + 1 print `cookie` ## -------------------------------------------------- cookies = [] for ac in aACs: cookies.append(ac[0]["aCookie"]) print cookies propnames = [IDLInterchange.kItemWeight, IDLInterchange.kDocTitle] results = aRS.GetItemsProperties(propnames, cookies) anItemsNames = results['aNames'] anItemsState = results['anItemsState'] for r in anItemsState: i = 0 for p in r: print propnames[i] + ": " + `dlcoslib.InputAny(p)` i = i + 1