Index: third_party/grpc/examples/python/route_guide/route_guide_resources.py |
diff --git a/third_party/WebKit/LayoutTests/http/tests/websocket/echo-with-no-extension_wsh.py b/third_party/grpc/examples/python/route_guide/route_guide_resources.py |
similarity index 67% |
copy from third_party/WebKit/LayoutTests/http/tests/websocket/echo-with-no-extension_wsh.py |
copy to third_party/grpc/examples/python/route_guide/route_guide_resources.py |
index 4206831cb5135d5e03928bf9d995b2bf9e156018..30c7711019fb6a220bb50093a223c4da28b766e6 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/websocket/echo-with-no-extension_wsh.py |
+++ b/third_party/grpc/examples/python/route_guide/route_guide_resources.py |
@@ -1,4 +1,4 @@ |
-# Copyright 2012, Google Inc. |
+# Copyright 2015, Google Inc. |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -27,22 +27,27 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+"""Common resources used in the gRPC route guide example.""" |
-_GOODBYE_MESSAGE = u'Goodbye' |
+import json |
+import route_guide_pb2 |
-def web_socket_do_extra_handshake(request): |
- request.ws_extension_processors = [] |
+def read_route_guide_database(): |
+ """Reads the route guide database. |
-def web_socket_transfer_data(request): |
- while True: |
- line = request.ws_stream.receive_message() |
- if line is None: |
- return |
- if isinstance(line, unicode): |
- request.ws_stream.send_message(line, binary=False) |
- if line == _GOODBYE_MESSAGE: |
- return |
- else: |
- request.ws_stream.send_message(line, binary=True) |
+ Returns: |
+ The full contents of the route guide database as a sequence of |
+ route_guide_pb2.Features. |
+ """ |
+ feature_list = [] |
+ with open("route_guide_db.json") as route_guide_db_file: |
+ for item in json.load(route_guide_db_file): |
+ feature = route_guide_pb2.Feature( |
+ name=item["name"], |
+ location=route_guide_pb2.Point( |
+ latitude=item["location"]["latitude"], |
+ longitude=item["location"]["longitude"])) |
+ feature_list.append(feature) |
+ return feature_list |