Fix protobuf generation and test file

* It seems that new versions of protobuf compiler requires the input
  protobuf file name to have a prefix of the --proto_path, relative
  path does not work in this case
* Fix two null exceptions in test/test.py where docid does not present
  in the query result
This commit is contained in:
ppoffice 2019-06-15 11:49:51 -04:00
parent 0ca0f65f75
commit 96387b2407
2 changed files with 5 additions and 3 deletions

View File

@ -20,7 +20,7 @@ class ProtobufBuilder(_build):
subprocess.run([PROTOC_BIN, subprocess.run([PROTOC_BIN,
"--proto_path=" + CURRENT_DIR, "--proto_path=" + CURRENT_DIR,
"--python_out=" + CURRENT_DIR + "/gpapi/", "--python_out=" + CURRENT_DIR + "/gpapi/",
"googleplay.proto"]) CURRENT_DIR + "/googleplay.proto"])
super().run() super().run()
setup(name='gpapi', setup(name='gpapi',

View File

@ -18,6 +18,7 @@ print(server.searchSuggest("fir"))
result = server.search("firefox") result = server.search("firefox")
for doc in result: for doc in result:
if 'docid' in doc:
print("doc: {}".format(doc["docid"])) print("doc: {}".format(doc["docid"]))
for cluster in doc["child"]: for cluster in doc["child"]:
print("\tcluster: {}".format(cluster["docid"])) print("\tcluster: {}".format(cluster["docid"]))
@ -80,6 +81,7 @@ print("\nBrowsing the {} category\n".format(sampleCat))
browseCat = server.home(cat=sampleCat) browseCat = server.home(cat=sampleCat)
for doc in browseCat: for doc in browseCat:
if 'docid' in doc:
print("doc: {}".format(doc["docid"])) print("doc: {}".format(doc["docid"]))
for child in doc["child"]: for child in doc["child"]:
print("\tsubcat: {}".format(child["docid"])) print("\tsubcat: {}".format(child["docid"]))