diff --git a/.gitignore b/.gitignore index 38f98b3..904b7ae 100644 --- a/.gitignore +++ b/.gitignore @@ -65,5 +65,8 @@ coverage.xml docs/_build/ _build +#Protobuf +*_pb2.py + # PyBuilder target/ diff --git a/.travis.yml b/.travis.yml index cf1d4a3..d3bd0bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,13 @@ sudo: false +env: + - BREW_HOME=$HOME/.linuxbrew + +# Protobuf is very expensive to install, so we cache it between builds +before_install: ./install-protobuf3.sh +cache: + directories: + - $BREW_HOME + language: python python: - "2.7" diff --git a/google/gax/__init__.py b/google/gax/__init__.py index bd2458a..fb609c2 100644 --- a/google/gax/__init__.py +++ b/google/gax/__init__.py @@ -33,7 +33,7 @@ import collections -__version__ = '0.12.0' +__version__ = '0.12.1' INITIAL_PAGE = object() diff --git a/google/gax/bundling.py b/google/gax/bundling.py index 9ee941a..a24d8d7 100644 --- a/google/gax/bundling.py +++ b/google/gax/bundling.py @@ -67,11 +67,9 @@ def _str_dotted_getattr(obj, name): Raises: AttributeError if the named attribute does not exist. """ - if name.find('.') == -1: - return getattr(obj, name) for part in name.split('.'): obj = getattr(obj, part) - return str(obj) if obj is not None else None + return str(obj) if obj else None def compute_bundle_id(obj, discriminator_fields): @@ -190,7 +188,9 @@ def _run_with_subresponses(self, req, subresponse_field, kwargs): for i, event in zip(in_sizes, self._event_deque): next_copy = copy.copy(resp) subresponses = all_subresponses[start:start + i] - setattr(next_copy, subresponse_field, subresponses) + # TODO: assumes we are using GRPC; abstract into config.py for portability + next_copy.ClearField(subresponse_field) + getattr(next_copy, subresponse_field).extend(subresponses) start += i event.result = next_copy event.set() diff --git a/install-protobuf3.sh b/install-protobuf3.sh new file mode 100755 index 0000000..8e17c60 --- /dev/null +++ b/install-protobuf3.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +export PATH="$BREW_HOME/bin:$PATH" + +echo "Testing for protoc command" +command -v protoc || { + echo "Testing for brew command" + command -v brew || { + echo "Installing brew" + # install brew in headless mode to avoid user prompt requiring input +