From 96387b2407060930819440a274d2a99f4851a0ba Mon Sep 17 00:00:00 2001 From: ppoffice Date: Sat, 15 Jun 2019 11:49:51 -0400 Subject: [PATCH] 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 --- setup.py | 2 +- test/test.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f2afb29..d6313ed 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ class ProtobufBuilder(_build): subprocess.run([PROTOC_BIN, "--proto_path=" + CURRENT_DIR, "--python_out=" + CURRENT_DIR + "/gpapi/", - "googleplay.proto"]) + CURRENT_DIR + "/googleplay.proto"]) super().run() setup(name='gpapi', diff --git a/test/test.py b/test/test.py index 495b7ee..ba78f0d 100644 --- a/test/test.py +++ b/test/test.py @@ -18,7 +18,8 @@ print(server.searchSuggest("fir")) result = server.search("firefox") for doc in result: - print("doc: {}".format(doc["docid"])) + if 'docid' in doc: + print("doc: {}".format(doc["docid"])) for cluster in doc["child"]: print("\tcluster: {}".format(cluster["docid"])) for app in cluster["child"]: @@ -80,7 +81,8 @@ print("\nBrowsing the {} category\n".format(sampleCat)) browseCat = server.home(cat=sampleCat) for doc in browseCat: - print("doc: {}".format(doc["docid"])) + if 'docid' in doc: + print("doc: {}".format(doc["docid"])) for child in doc["child"]: print("\tsubcat: {}".format(child["docid"])) for app in child["child"]: