From 6351867ef47d626fe5af0cae3a33f97d5c4c681b Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 10:17:28 -0800 Subject: [PATCH 01/13] Update to latest google-cloud-python Change-Id: I11180caa0f97743fc3475e05fc44d5686702aabd --- appengine/flexible/analytics/requirements.txt | 2 +- appengine/flexible/datastore/requirements.txt | 2 +- appengine/flexible/endpoints/requirements.txt | 2 +- appengine/flexible/kinto/requirements.txt | 2 +- appengine/flexible/mailgun/requirements.txt | 2 +- appengine/flexible/mailjet/requirements.txt | 2 +- appengine/flexible/metadata/requirements.txt | 2 +- .../gateway-service/requirements.txt | 2 +- .../static-service/requirements.txt | 2 +- appengine/flexible/pubsub/requirements.txt | 2 +- appengine/flexible/sendgrid/requirements.txt | 2 +- appengine/flexible/storage/requirements.txt | 2 +- appengine/standard/analytics/requirements.txt | 2 +- .../firebase/firetactoe/requirements.txt | 2 +- appengine/standard/mailjet/requirements.txt | 2 +- appengine/standard/sendgrid/requirements.txt | 2 +- .../urlfetch/requests/requirements.txt | 2 +- bigquery/cloud-client/requirements.txt | 2 +- bigquery/dml/requirements.txt | 4 +- bigtable/hello/requirements.txt | 2 +- .../requirements.txt | 2 +- compute/auth/requirements.txt | 2 +- compute/encryption/requirements.txt | 2 +- compute/metadata/requirements.txt | 2 +- compute/xmpp_wikibot/requirements.txt | 2 +- dataproc/requirements.txt | 2 +- datastore/cloud-client/requirements.txt | 2 +- dns/api/requirements.txt | 2 +- endpoints/getting-started/requirements.txt | 2 +- language/movie_nl/requirements.txt | 2 +- logging/cloud-client/requirements.txt | 2 +- pubsub/cloud-client/requirements.txt | 2 +- speech/grpc/requirements.txt | 2 +- storage/cloud-client/requirements.txt | 2 +- testing/requirements-dev.in | 2 +- testing/requirements-dev.txt | 37 +++++++++---------- vision/cloud-client/requirements.txt | 2 +- 37 files changed, 55 insertions(+), 56 deletions(-) diff --git a/appengine/flexible/analytics/requirements.txt b/appengine/flexible/analytics/requirements.txt index bbdb73b006d8..620a68c926f0 100644 --- a/appengine/flexible/analytics/requirements.txt +++ b/appengine/flexible/analytics/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 gunicorn==19.6.0 -requests[security]==2.11.1 +requests[security]==2.12.0 diff --git a/appengine/flexible/datastore/requirements.txt b/appengine/flexible/datastore/requirements.txt index e772482ea7ce..16bdd7e83154 100644 --- a/appengine/flexible/datastore/requirements.txt +++ b/appengine/flexible/datastore/requirements.txt @@ -1,4 +1,4 @@ Flask==0.11.1 -google-cloud-datastore==0.20.1 +google-cloud-datastore==0.21.0 gunicorn==19.6.0 oauth2client==4.0.0 diff --git a/appengine/flexible/endpoints/requirements.txt b/appengine/flexible/endpoints/requirements.txt index 45699fbc037f..35ee5939e552 100644 --- a/appengine/flexible/endpoints/requirements.txt +++ b/appengine/flexible/endpoints/requirements.txt @@ -3,4 +3,4 @@ flask-cors==3.0.2 gunicorn==19.6.0 six==1.10.0 pyyaml==3.12 -requests==2.11.1 +requests==2.12.0 diff --git a/appengine/flexible/kinto/requirements.txt b/appengine/flexible/kinto/requirements.txt index 9108bb2bcdaf..95fe80eefdb1 100644 --- a/appengine/flexible/kinto/requirements.txt +++ b/appengine/flexible/kinto/requirements.txt @@ -1,3 +1,3 @@ gunicorn==19.6.0 oauth2client==4.0.0 -kinto==4.3.2 +kinto==4.3.3 diff --git a/appengine/flexible/mailgun/requirements.txt b/appengine/flexible/mailgun/requirements.txt index bbdb73b006d8..620a68c926f0 100644 --- a/appengine/flexible/mailgun/requirements.txt +++ b/appengine/flexible/mailgun/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 gunicorn==19.6.0 -requests[security]==2.11.1 +requests[security]==2.12.0 diff --git a/appengine/flexible/mailjet/requirements.txt b/appengine/flexible/mailjet/requirements.txt index cb0120b9f8cb..e05fc6545c33 100644 --- a/appengine/flexible/mailjet/requirements.txt +++ b/appengine/flexible/mailjet/requirements.txt @@ -1,4 +1,4 @@ Flask==0.11.1 gunicorn==19.6.0 -requests[security]==2.11.1 +requests[security]==2.12.0 mailjet-rest==v1.2.2 diff --git a/appengine/flexible/metadata/requirements.txt b/appengine/flexible/metadata/requirements.txt index bbdb73b006d8..620a68c926f0 100644 --- a/appengine/flexible/metadata/requirements.txt +++ b/appengine/flexible/metadata/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 gunicorn==19.6.0 -requests[security]==2.11.1 +requests[security]==2.12.0 diff --git a/appengine/flexible/multiple_services/gateway-service/requirements.txt b/appengine/flexible/multiple_services/gateway-service/requirements.txt index db7208b11cd0..f19f1bbd97c4 100644 --- a/appengine/flexible/multiple_services/gateway-service/requirements.txt +++ b/appengine/flexible/multiple_services/gateway-service/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 gunicorn==19.6.0 -requests==2.11.1 +requests==2.12.0 diff --git a/appengine/flexible/multiple_services/static-service/requirements.txt b/appengine/flexible/multiple_services/static-service/requirements.txt index db7208b11cd0..f19f1bbd97c4 100644 --- a/appengine/flexible/multiple_services/static-service/requirements.txt +++ b/appengine/flexible/multiple_services/static-service/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 gunicorn==19.6.0 -requests==2.11.1 +requests==2.12.0 diff --git a/appengine/flexible/pubsub/requirements.txt b/appengine/flexible/pubsub/requirements.txt index c297d66713df..fb59bbcc3adc 100644 --- a/appengine/flexible/pubsub/requirements.txt +++ b/appengine/flexible/pubsub/requirements.txt @@ -1,4 +1,4 @@ Flask==0.11.1 -google-cloud-pubsub==0.20.0 +google-cloud-pubsub==0.21.0 gunicorn==19.6.0 oauth2client==4.0.0 diff --git a/appengine/flexible/sendgrid/requirements.txt b/appengine/flexible/sendgrid/requirements.txt index b8148ab66bbe..597a0e256f8d 100644 --- a/appengine/flexible/sendgrid/requirements.txt +++ b/appengine/flexible/sendgrid/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 -sendgrid==3.6.2 +sendgrid==3.6.3 gunicorn==19.6.0 diff --git a/appengine/flexible/storage/requirements.txt b/appengine/flexible/storage/requirements.txt index a0ffd863192c..adaac404f1f5 100644 --- a/appengine/flexible/storage/requirements.txt +++ b/appengine/flexible/storage/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 -google-cloud-storage==0.20.0 +google-cloud-storage==0.21.0 gunicorn==19.6.0 diff --git a/appengine/standard/analytics/requirements.txt b/appengine/standard/analytics/requirements.txt index 50bd894d3b53..c545dbd8b71e 100644 --- a/appengine/standard/analytics/requirements.txt +++ b/appengine/standard/analytics/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 -requests==2.11.1 +requests==2.12.0 requests-toolbelt==0.7.0 diff --git a/appengine/standard/firebase/firetactoe/requirements.txt b/appengine/standard/firebase/firetactoe/requirements.txt index 535f170aac2f..1fc6a2a59f7a 100644 --- a/appengine/standard/firebase/firetactoe/requirements.txt +++ b/appengine/standard/firebase/firetactoe/requirements.txt @@ -1,5 +1,5 @@ flask==0.11.1 -requests==2.11.1 +requests==2.12.0 requests_toolbelt==0.7.0 oauth2client==4.0.0 functools32==3.2.3-2; python_version < "3" diff --git a/appengine/standard/mailjet/requirements.txt b/appengine/standard/mailjet/requirements.txt index 8e3e8a598d08..705ff274bc3a 100644 --- a/appengine/standard/mailjet/requirements.txt +++ b/appengine/standard/mailjet/requirements.txt @@ -1,4 +1,4 @@ Flask==0.11.1 -requests==2.11.1 +requests==2.12.0 requests-toolbelt==0.7.0 mailjet-rest==v1.2.2 diff --git a/appengine/standard/sendgrid/requirements.txt b/appengine/standard/sendgrid/requirements.txt index de5999970473..51864ac14c79 100644 --- a/appengine/standard/sendgrid/requirements.txt +++ b/appengine/standard/sendgrid/requirements.txt @@ -1 +1 @@ -sendgrid==3.6.2 +sendgrid==3.6.3 diff --git a/appengine/standard/urlfetch/requests/requirements.txt b/appengine/standard/urlfetch/requests/requirements.txt index 50bd894d3b53..c545dbd8b71e 100644 --- a/appengine/standard/urlfetch/requests/requirements.txt +++ b/appengine/standard/urlfetch/requests/requirements.txt @@ -1,3 +1,3 @@ Flask==0.11.1 -requests==2.11.1 +requests==2.12.0 requests-toolbelt==0.7.0 diff --git a/bigquery/cloud-client/requirements.txt b/bigquery/cloud-client/requirements.txt index 11a303264935..d9f269ca7b63 100644 --- a/bigquery/cloud-client/requirements.txt +++ b/bigquery/cloud-client/requirements.txt @@ -1 +1 @@ -google-cloud-bigquery==0.20.0 +google-cloud-bigquery==0.21.0 diff --git a/bigquery/dml/requirements.txt b/bigquery/dml/requirements.txt index 289896af1483..d50a20abea46 100644 --- a/bigquery/dml/requirements.txt +++ b/bigquery/dml/requirements.txt @@ -1,5 +1,5 @@ -flake8==3.0.4 -google-cloud-bigquery==0.20.0 +flake8==3.2.0 +google-cloud-bigquery==0.21.0 PyMySQL==0.7.9 six==1.10.0 SQLAlchemy==1.1.3 diff --git a/bigtable/hello/requirements.txt b/bigtable/hello/requirements.txt index faf739f846d1..2a416a31f8f2 100644 --- a/bigtable/hello/requirements.txt +++ b/bigtable/hello/requirements.txt @@ -1 +1 @@ -google-cloud-bigtable==0.20.0 +google-cloud-bigtable==0.21.0 diff --git a/blog/introduction_to_data_models_in_cloud_datastore/requirements.txt b/blog/introduction_to_data_models_in_cloud_datastore/requirements.txt index ccc49e93cab6..29dc975fb3d5 100644 --- a/blog/introduction_to_data_models_in_cloud_datastore/requirements.txt +++ b/blog/introduction_to_data_models_in_cloud_datastore/requirements.txt @@ -1 +1 @@ -google-cloud-datastore==0.20.1 +google-cloud-datastore==0.21.0 diff --git a/compute/auth/requirements.txt b/compute/auth/requirements.txt index b6f2e0128beb..7242fd505c3d 100644 --- a/compute/auth/requirements.txt +++ b/compute/auth/requirements.txt @@ -1,2 +1,2 @@ -requests==2.11.1 +requests==2.12.0 google-api-python-client==1.5.5 diff --git a/compute/encryption/requirements.txt b/compute/encryption/requirements.txt index e8591f351561..f5aa404ba7f2 100644 --- a/compute/encryption/requirements.txt +++ b/compute/encryption/requirements.txt @@ -1,2 +1,2 @@ cryptography==1.5.3 -requests==2.11.1 +requests==2.12.0 diff --git a/compute/metadata/requirements.txt b/compute/metadata/requirements.txt index 466103081b66..b37f3801047f 100644 --- a/compute/metadata/requirements.txt +++ b/compute/metadata/requirements.txt @@ -1 +1 @@ -requests==2.11.1 +requests==2.12.0 diff --git a/compute/xmpp_wikibot/requirements.txt b/compute/xmpp_wikibot/requirements.txt index 217aa31c80b6..d8e12de0fb87 100644 --- a/compute/xmpp_wikibot/requirements.txt +++ b/compute/xmpp_wikibot/requirements.txt @@ -1,4 +1,4 @@ Flask==0.11.1 -requests==2.11.1 +requests==2.12.0 sleekxmpp==1.3.1 six==1.10.0 diff --git a/dataproc/requirements.txt b/dataproc/requirements.txt index 6ac114bc48dc..d291ebf7aa8f 100644 --- a/dataproc/requirements.txt +++ b/dataproc/requirements.txt @@ -1,2 +1,2 @@ google-api-python-client==1.5.5 -google-cloud==0.20.0 +google-cloud==0.21.0 diff --git a/datastore/cloud-client/requirements.txt b/datastore/cloud-client/requirements.txt index ccc49e93cab6..29dc975fb3d5 100644 --- a/datastore/cloud-client/requirements.txt +++ b/datastore/cloud-client/requirements.txt @@ -1 +1 @@ -google-cloud-datastore==0.20.1 +google-cloud-datastore==0.21.0 diff --git a/dns/api/requirements.txt b/dns/api/requirements.txt index ed5da71cc167..3138fa7601e1 100644 --- a/dns/api/requirements.txt +++ b/dns/api/requirements.txt @@ -1 +1 @@ -google-cloud-dns==0.20.0 +google-cloud-dns==0.21.0 diff --git a/endpoints/getting-started/requirements.txt b/endpoints/getting-started/requirements.txt index 45699fbc037f..35ee5939e552 100644 --- a/endpoints/getting-started/requirements.txt +++ b/endpoints/getting-started/requirements.txt @@ -3,4 +3,4 @@ flask-cors==3.0.2 gunicorn==19.6.0 six==1.10.0 pyyaml==3.12 -requests==2.11.1 +requests==2.12.0 diff --git a/language/movie_nl/requirements.txt b/language/movie_nl/requirements.txt index 7a0de85468fa..f552f7468eb6 100644 --- a/language/movie_nl/requirements.txt +++ b/language/movie_nl/requirements.txt @@ -1,2 +1,2 @@ google-api-python-client==1.5.5 -requests==2.11.1 +requests==2.12.0 diff --git a/logging/cloud-client/requirements.txt b/logging/cloud-client/requirements.txt index 303f67c091c9..ce5d85c60e7c 100644 --- a/logging/cloud-client/requirements.txt +++ b/logging/cloud-client/requirements.txt @@ -1 +1 @@ -google-cloud-logging==0.20.0 +google-cloud-logging==0.21.0 diff --git a/pubsub/cloud-client/requirements.txt b/pubsub/cloud-client/requirements.txt index 7aa8ce1fbd11..f2fc2b4a2aa0 100644 --- a/pubsub/cloud-client/requirements.txt +++ b/pubsub/cloud-client/requirements.txt @@ -1 +1 @@ -google-cloud-pubsub==0.20.0 +google-cloud-pubsub==0.21.0 diff --git a/speech/grpc/requirements.txt b/speech/grpc/requirements.txt index 582065ec1428..0f312db88ae1 100644 --- a/speech/grpc/requirements.txt +++ b/speech/grpc/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-core==0.20.0 +google-cloud-core==0.21.0 grpcio==1.0.1 PyAudio==0.2.9 grpc-google-cloud-speech-v1beta1==1.0.1 diff --git a/storage/cloud-client/requirements.txt b/storage/cloud-client/requirements.txt index 303fed123d80..025b3c37ad37 100644 --- a/storage/cloud-client/requirements.txt +++ b/storage/cloud-client/requirements.txt @@ -1 +1 @@ -google-cloud-storage==0.20.0 +google-cloud-storage==0.21.0 diff --git a/testing/requirements-dev.in b/testing/requirements-dev.in index 03ad62ab93e9..46e415ffcc77 100644 --- a/testing/requirements-dev.in +++ b/testing/requirements-dev.in @@ -6,7 +6,7 @@ mock==2.0.0 mysql-python==1.2.5 PyCrypto==2.6.1 pytest-cov==2.4.0 -pytest==3.0.3 +pytest==3.0.4 pyyaml==3.12 responses==0.5.1 WebTest==2.0.23 diff --git a/testing/requirements-dev.txt b/testing/requirements-dev.txt index d0118964875e..5b1c7e629d0a 100644 --- a/testing/requirements-dev.txt +++ b/testing/requirements-dev.txt @@ -3,7 +3,7 @@ beautifulsoup4==4.5.1 coverage==4.2 cryptography==1.5.3 Django==1.10.3 -flake8==3.0.4 +flake8==3.2.0 flaky==3.3.0 flask-cors==3.0.2 Flask-SQLAlchemy==2.1 @@ -13,24 +13,24 @@ fluent-logger==0.4.4 funcsigs==1.0.2 functools32==3.2.3-2; python_version < "3" google-api-python-client==1.5.5 -google-cloud-bigquery==0.20.0 -google-cloud-bigtable==0.20.0 -google-cloud-core==0.20.0 -google-cloud-datastore==0.20.1 -google-cloud-dns==0.20.0 +google-cloud-bigquery==0.21.0 +google-cloud-bigtable==0.21.0 +google-cloud-core==0.21.0 +google-cloud-datastore==0.21.0 +google-cloud-dns==0.21.0 google-cloud-happybase==0.20.0 -google-cloud-language==0.20.0 -google-cloud-logging==0.20.0 -google-cloud-pubsub==0.20.0 -google-cloud-storage==0.20.0 -google-cloud-translate==0.20.0 -google-cloud-vision==0.20.0 -google-cloud==0.20.0 +google-cloud-language==0.21.0 +google-cloud-logging==0.21.0 +google-cloud-pubsub==0.21.0 +google-cloud-storage==0.21.0 +google-cloud-translate==0.21.0 +google-cloud-vision==0.21.0 +google-cloud==0.21.0 grpc-google-cloud-speech-v1beta1==1.0.1 grpcio==1.0.1 gunicorn==19.6.0 httplib2==0.9.2 -kinto==4.3.2 +kinto==4.3.3 mailjet-rest==v1.2.2 mock==2.0.0 mysql-python==1.2.5; python_version == '2.7' @@ -43,20 +43,19 @@ pyasn1==0.1.9 PyAudio==0.2.9 PyCrypto==2.6.1 pyjwt==1.4.2 -pylibmc==1.5.1 PyMySQL==0.7.9 pytest-cov==2.4.0 -pytest==3.0.3 +pytest==3.0.4 pyyaml==3.12 redis==2.10.5 requests-toolbelt==0.7.0 -requests==2.11.1 -requests[security]==2.11.1 +requests==2.12.0 +requests[security]==2.12.0 requests_toolbelt==0.7.0 responses==0.5.1 rsa==3.4.2 scipy==0.18.1 -sendgrid==3.6.2 +sendgrid==3.6.3 simplejson==3.10.0 six==1.10.0 sleekxmpp==1.3.1 diff --git a/vision/cloud-client/requirements.txt b/vision/cloud-client/requirements.txt index f549e6d149ef..c2a564db5962 100644 --- a/vision/cloud-client/requirements.txt +++ b/vision/cloud-client/requirements.txt @@ -1 +1 @@ -google-cloud-vision==0.20.0 +google-cloud-vision==0.21.0 From d1066407d4269c122d04172f6b2e030ac055dbdb Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 10:17:37 -0800 Subject: [PATCH 02/13] Fix some minor nox issues Change-Id: I78ceda896df08c433620b3a40e21fef7bb72f4a2 --- nox.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nox.py b/nox.py index 664540e5710f..0824c0f7b011 100644 --- a/nox.py +++ b/nox.py @@ -48,6 +48,7 @@ # Libraries that only work on Python 2.7 PY27_ONLY_LIBRARIES = ['mysql-python'] +IGNORED_LIBRARIES = ['pylibmc'] # Whether we're running on Travis CI ON_TRAVIS = os.environ.get('TRAVIS', False) @@ -245,7 +246,7 @@ def session_lint(session): sample_directories = ( sample_dir for subdir in subdirs if not subdir.startswith('.') for sample_dir in collect_sample_dirs( - subdir, suffix='.py', blacklist='conftest.py')) + subdir, suffix='.py', blacklist='conftest.py')) # On travis, only lint changed samples. if ON_TRAVIS: @@ -286,7 +287,7 @@ def session_reqcheck(session): command = 'check-requirements' reqfiles = list(list_files('.', 'requirements*.txt')) - reqfiles.append('requirements-dev.in') + reqfiles.append('testing/requirements-dev.in') for reqfile in reqfiles: session.run('gcprepotools', command, reqfile) @@ -297,6 +298,7 @@ def session_reqrollup(session): This does not test for uniqueness. pip itself will validate that. """ + session.virtualenv = False requirements = set() requirements_files = list(list_files('.', 'requirements*.txt')) requirements_files.append('./testing/requirements-dev.in') @@ -317,9 +319,19 @@ def mark_if_necessary(requirement): requirement.strip()) return requirement + def is_ignored(requirement): + """Ignores certain libraries.""" + for library in IGNORED_LIBRARIES: + if requirement.startswith(library): + return True + requirements = [ mark_if_necessary(requirement) for requirement in requirements] + requirements = [ + requirement for requirement in requirements if not + is_ignored(requirement)] + with open('testing/requirements-dev.txt', 'w') as f: f.write('# This file is generated by nox -s reqrollup. Do not edit.\n') for requirement in sorted(requirements, key=lambda s: s.lower()): From 91847caf85ed2b40efb18a3f3715e476c824154b Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 10:18:00 -0800 Subject: [PATCH 03/13] Update datastore samples for new google-cloud-python Change-Id: I07d16616e373d925f6ce5e9e47ab2fb7d073eb59 --- datastore/cloud-client/snippets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/datastore/cloud-client/snippets.py b/datastore/cloud-client/snippets.py index ed6c62da79ed..69e5e87d2a69 100644 --- a/datastore/cloud-client/snippets.py +++ b/datastore/cloud-client/snippets.py @@ -362,9 +362,12 @@ def cursor_paging(client): def get_one_page_of_tasks(cursor=None): query = client.query(kind='Task') query_iter = query.fetch(start_cursor=cursor, limit=5) - tasks, _, cursor = query_iter.next_page() + page = next(query_iter.pages) - return tasks, cursor + tasks = list(page) + next_cusor = query_iter.next_page_token + + return tasks, next_cusor # [END cursor_paging] page_one, cursor_one = get_one_page_of_tasks() From 1374be3d33d9ceab68165c79e2220ef39606fc57 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 10:59:54 -0800 Subject: [PATCH 04/13] Update bigquery samples to use latest google-cloud Change-Id: I6cbcca11be84baa7c40eed14b342cc916b9116d9 --- bigquery/cloud-client/snippets.py | 55 ++++--------------------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/bigquery/cloud-client/snippets.py b/bigquery/cloud-client/snippets.py index f7ab33731058..61d498223033 100644 --- a/bigquery/cloud-client/snippets.py +++ b/bigquery/cloud-client/snippets.py @@ -35,18 +35,7 @@ def list_projects(): bigquery_client = bigquery.Client() - projects = [] - page_token = None - - while True: - results, page_token = bigquery_client.list_projects( - page_token=page_token) - projects.extend(results) - - if not page_token: - break - - for project in projects: + for project in bigquery_client.list_projects(): print(project.project_id) @@ -57,18 +46,7 @@ def list_datasets(project=None): """ bigquery_client = bigquery.Client(project=project) - datasets = [] - page_token = None - - while True: - results, page_token = bigquery_client.list_datasets( - page_token=page_token) - datasets.extend(results) - - if not page_token: - break - - for dataset in datasets: + for dataset in bigquery_client.list_datasets(): print(dataset.name) @@ -98,17 +76,7 @@ def list_tables(dataset_name, project=None): print('Dataset {} does not exist.'.format(dataset_name)) return - tables = [] - page_token = None - - while True: - results, page_token = dataset.list_tables(page_token=page_token) - tables.extend(results) - - if not page_token: - break - - for table in tables: + for table in dataset.list_tables(): print(table.name) @@ -157,19 +125,10 @@ def list_rows(dataset_name, table_name, project=None): # Reload the table so that the schema is available. table.reload() - rows = [] - page_token = None - - # Load at most 25 results. You can change this to `while True` and change - # the max_results argument to load more rows from BigQuery, but note - # that this can take some time. It's preferred to use a query. - while len(rows) < 25: - results, total_rows, page_token = table.fetch_data( - max_results=25, page_token=page_token) - rows.extend(results) - - if not page_token: - break + # Load at most 25 results. You can change the max_results argument to load + # more rows from BigQuery, but note that this can take some time. It's + # preferred to use a query. + rows = table.fetch_data(max_results=25) # Use format to create a simple table. format_string = '{!s:<16} ' * len(table.schema) From 20d9de90bdc1ac2eb3a608c1c3399942bc7bf10a Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 11:00:07 -0800 Subject: [PATCH 05/13] Update dns samples to use latest google-cloud Change-Id: Ibd8cc3b651e666c5c5e7d9537a690cf4e9acc03a --- dns/api/main.py | 10 +++------- dns/api/main_test.py | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dns/api/main.py b/dns/api/main.py index 2ed3d61d7c37..f18517d2dea4 100644 --- a/dns/api/main.py +++ b/dns/api/main.py @@ -45,7 +45,7 @@ def get_zone(project_id, name): # [START list_zones] def list_zones(project_id): client = dns.Client(project=project_id) - zones, _ = client.list_zones() + zones = client.list_zones() return [zone.name for zone in zones] # [END list_zones] @@ -63,11 +63,7 @@ def list_resource_records(project_id, zone_name): client = dns.Client(project=project_id) zone = client.zone(zone_name) - records, page_token = zone.list_resource_record_sets() - while page_token is not None: - next_batch, page_token = zone.list_resource_record_sets( - page_token=page_token) - records.extend(next_batch) + records = zone.list_resource_record_sets() return [(record.name, record.record_type, record.ttl, record.rrdatas) for record in records] @@ -79,7 +75,7 @@ def list_changes(project_id, zone_name): client = dns.Client(project=project_id) zone = client.zone(zone_name) - changes, _ = zone.list_changes() + changes = zone.list_changes() return [(change.started, change.status) for change in changes] # [END changes] diff --git a/dns/api/main_test.py b/dns/api/main_test.py index 21b02ae2e271..be6dfef78b5d 100644 --- a/dns/api/main_test.py +++ b/dns/api/main_test.py @@ -29,7 +29,7 @@ def client(cloud_config): yield client # Delete anything created during the test. - for zone in client.list_zones()[0]: + for zone in client.list_zones(): zone.delete() From 11575bc12f6e5ed59b91a6692625b0046a4c9ac2 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 11:00:22 -0800 Subject: [PATCH 06/13] Update logging samples to use latest google-cloud Change-Id: I3ea731e4022610802b262a93197dee17b2e09838 --- logging/cloud-client/export.py | 8 +------- logging/cloud-client/snippets.py | 11 +---------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/logging/cloud-client/export.py b/logging/cloud-client/export.py index 20367c274b21..f8c1f0c5f954 100644 --- a/logging/cloud-client/export.py +++ b/logging/cloud-client/export.py @@ -23,13 +23,7 @@ def list_sinks(): """Lists all sinks.""" logging_client = logging.Client() - sinks = [] - token = None - while True: - new_sinks, token = logging_client.list_sinks(page_token=token) - sinks.extend(new_sinks) - if token is None: - break + sinks = list(logging_client.list_sinks()) if not sinks: print('No sinks.') diff --git a/logging/cloud-client/snippets.py b/logging/cloud-client/snippets.py index 0280cfbe4063..8a31066fa3bb 100644 --- a/logging/cloud-client/snippets.py +++ b/logging/cloud-client/snippets.py @@ -56,16 +56,7 @@ def list_entries(logger_name): print('Listing entries for logger {}:'.format(logger.name)) - entries = [] - page_token = None - - while True: - new_entries, page_token = logger.list_entries(page_token=page_token) - entries.extend(new_entries) - if not page_token: - break - - for entry in entries: + for entry in logger.list_entries(): timestamp = entry.timestamp.isoformat() print('* {}: {}'.format (timestamp, entry.payload)) From f691fbd6ade087ac9dc9209c9ccc17b7f0262ff3 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 11:00:34 -0800 Subject: [PATCH 07/13] Update pubsub samples to use latest google-cloud Change-Id: Iac57ac0708fadc11f358c1599f4d1ce94b0dac8b --- pubsub/cloud-client/publisher.py | 10 +--------- pubsub/cloud-client/subscriber.py | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/pubsub/cloud-client/publisher.py b/pubsub/cloud-client/publisher.py index d527b54cb1c4..465047560565 100644 --- a/pubsub/cloud-client/publisher.py +++ b/pubsub/cloud-client/publisher.py @@ -30,15 +30,7 @@ def list_topics(): """Lists all Pub/Sub topics in the current project.""" pubsub_client = pubsub.Client() - topics = [] - next_page_token = None - while True: - page, next_page_token = pubsub_client.list_topics() - topics.extend(page) - if not next_page_token: - break - - for topic in topics: + for topic in pubsub_client.list_topics(): print(topic.name) diff --git a/pubsub/cloud-client/subscriber.py b/pubsub/cloud-client/subscriber.py index b4fdd95738d1..9a564496e424 100644 --- a/pubsub/cloud-client/subscriber.py +++ b/pubsub/cloud-client/subscriber.py @@ -31,15 +31,7 @@ def list_subscriptions(topic_name): pubsub_client = pubsub.Client() topic = pubsub_client.topic(topic_name) - subscriptions = [] - next_page_token = None - while True: - page, next_page_token = topic.list_subscriptions() - subscriptions.extend(page) - if not next_page_token: - break - - for subscription in subscriptions: + for subscription in topic.list_subscriptions(): print(subscription.name) From 22e3d531aac2d58fceea51de9b8bc9d498044f42 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 11:00:45 -0800 Subject: [PATCH 08/13] Update storage samples to use latest google-cloud Change-Id: Ic9731e804792aeaeee51ca87ab7dc5971fe7ef5b --- storage/cloud-client/encryption.py | 10 ++++------ storage/cloud-client/encryption_test.py | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/storage/cloud-client/encryption.py b/storage/cloud-client/encryption.py index d15be17c2af3..782e70b5c53f 100644 --- a/storage/cloud-client/encryption.py +++ b/storage/cloud-client/encryption.py @@ -62,10 +62,9 @@ def upload_encrypted_blob(bucket_name, source_file_name, # Encryption key must be an AES256 key represented as a bytestring with # 32 bytes. Since it's passed in as a base64 encoded string, it needs # to be decoded. - encryption_key = base64.b64decode(base64_encryption_key) + blob.encryption_key = base64.b64decode(base64_encryption_key) - blob.upload_from_filename( - source_file_name, encryption_key=encryption_key) + blob.upload_from_filename(source_file_name) print('File {} uploaded to {}.'.format( source_file_name, @@ -86,10 +85,9 @@ def download_encrypted_blob(bucket_name, source_blob_name, # Encryption key must be an AES256 key represented as a bytestring with # 32 bytes. Since it's passed in as a base64 encoded string, it needs # to be decoded. - encryption_key = base64.b64decode(base64_encryption_key) + blob.encryption_key = base64.b64decode(base64_encryption_key) - blob.download_to_filename( - destination_file_name, encryption_key=encryption_key) + blob.download_to_filename(destination_file_name) print('Blob {} downloaded to {}.'.format( source_blob_name, diff --git a/storage/cloud-client/encryption_test.py b/storage/cloud-client/encryption_test.py index 28fa5e3b8959..926be643c59d 100644 --- a/storage/cloud-client/encryption_test.py +++ b/storage/cloud-client/encryption_test.py @@ -49,9 +49,8 @@ def test_blob(cloud_config): bucket = storage.Client().bucket(cloud_config.storage_bucket) blob = bucket.blob('encryption_test_sigil') content = 'Hello, is it me you\'re looking for?' - blob.upload_from_string( - content, - encryption_key=TEST_ENCRYPTION_KEY_DECODED) + blob.encryption_key = TEST_ENCRYPTION_KEY_DECODED + blob.upload_from_string(content) return blob.name, content From 03b27e8b64129cdef8d7b077f65dcd3691ba8993 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 11:19:53 -0800 Subject: [PATCH 09/13] Fix lint Change-Id: Ibb9430ba18ac4c73608495c6ff3b050582040512 --- appengine/flexible/datastore/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/appengine/flexible/datastore/main.py b/appengine/flexible/datastore/main.py index bd19a0de9b94..3130edd53ff5 100644 --- a/appengine/flexible/datastore/main.py +++ b/appengine/flexible/datastore/main.py @@ -14,7 +14,6 @@ import datetime import logging -import os import socket from flask import Flask, request From 356898100101db14b00ae70000530fa546fba1a6 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 13:23:22 -0800 Subject: [PATCH 10/13] Fix lint Change-Id: I059b64397a783643a21ee75bf2d54082ce5cb23c --- appengine/flexible/hello_world/main.py | 1 + appengine/flexible/numpy/main.py | 1 + appengine/standard/app_identity/asserting/main.py | 1 + appengine/standard/app_identity/incoming/main.py | 1 + appengine/standard/appstats/main.py | 1 + appengine/standard/background/main.py | 1 + appengine/standard/channel/chatactoe.py | 1 + appengine/standard/endpoints/multiapi/main.py | 1 + appengine/standard/hello_world/main.py | 1 + appengine/standard/localtesting/env_vars_test.py | 1 + appengine/standard/localtesting/login_test.py | 1 + appengine/standard/localtesting/mail_test.py | 1 + appengine/standard/localtesting/task_queue_test.py | 1 + appengine/standard/mail/handle_bounced_email.py | 1 + appengine/standard/mail/handle_incoming_email.py | 1 + appengine/standard/memcache/best_practices/batch/batch.py | 1 + appengine/standard/modules/main.py | 1 + appengine/standard/ndb/async/app_async.py | 1 + appengine/standard/ndb/async/app_sync.py | 1 + appengine/standard/xmpp/xmpp.py | 1 + bigquery/api/list_datasets_projects.py | 1 + bigquery/api/load_data_by_post.py | 1 + dataproc/list_clusters.py | 1 + datastore/cloud-client/snippets.py | 4 ++-- error_reporting/main.py | 1 + scripts/auto_link_to_docs.py | 1 + scripts/readme-gen/readme_gen.py | 1 + speech/api-client/transcribe.py | 1 + storage/transfer_service/aws_request.py | 1 + storage/transfer_service/nearline_request.py | 1 + storage/transfer_service/transfer_check.py | 1 + vision/api/label/label.py | 1 + 32 files changed, 33 insertions(+), 2 deletions(-) diff --git a/appengine/flexible/hello_world/main.py b/appengine/flexible/hello_world/main.py index ae08dcdfa6e6..97eb37d83a2d 100644 --- a/appengine/flexible/hello_world/main.py +++ b/appengine/flexible/hello_world/main.py @@ -35,6 +35,7 @@ def server_error(e): See logs for full stacktrace. """.format(e), 500 + if __name__ == '__main__': # This is used when running locally. Gunicorn is used to run the # application on Google App Engine. See entrypoint in app.yaml. diff --git a/appengine/flexible/numpy/main.py b/appengine/flexible/numpy/main.py index cf6ba319f3e3..77f04de8a2c6 100644 --- a/appengine/flexible/numpy/main.py +++ b/appengine/flexible/numpy/main.py @@ -43,6 +43,7 @@ def server_error(e): See logs for full stacktrace. """.format(e), 500 + if __name__ == '__main__': # This is used when running locally. Gunicorn is used to run the # application on Google App Engine. See entrypoint in app.yaml. diff --git a/appengine/standard/app_identity/asserting/main.py b/appengine/standard/app_identity/asserting/main.py index d0c216b5db02..00d76e7e0976 100644 --- a/appengine/standard/app_identity/asserting/main.py +++ b/appengine/standard/app_identity/asserting/main.py @@ -54,6 +54,7 @@ def get(self): self.response.headers['Content-Type'] = 'application/json' self.response.write(json.dumps(result, indent=2)) + app = webapp2.WSGIApplication([ ('/', MainPage) ], debug=True) diff --git a/appengine/standard/app_identity/incoming/main.py b/appengine/standard/app_identity/incoming/main.py index f7c25f51afb8..68705ccd134e 100644 --- a/appengine/standard/app_identity/incoming/main.py +++ b/appengine/standard/app_identity/incoming/main.py @@ -38,6 +38,7 @@ def get(self): self.response.write('This is a protected page.') + app = webapp2.WSGIApplication([ ('/', MainPage) ], debug=True) diff --git a/appengine/standard/appstats/main.py b/appengine/standard/appstats/main.py index 8059336a4af5..06257a177826 100644 --- a/appengine/standard/appstats/main.py +++ b/appengine/standard/appstats/main.py @@ -30,6 +30,7 @@ def get(self): value = memcache.get('example_key') self.response.write('Value is: {}'.format(value)) + app = webapp2.WSGIApplication([ ('/', MainPage) ], debug=True) diff --git a/appengine/standard/background/main.py b/appengine/standard/background/main.py index 1709d4a962bb..7a1d7be59285 100644 --- a/appengine/standard/background/main.py +++ b/appengine/standard/background/main.py @@ -77,6 +77,7 @@ def change_val(arg): self.response.headers['Content-Type'] = 'text/plain' self.response.write('Done') + app = webapp2.WSGIApplication([ ('/', MainHandler), ('/dog', SetDogHandler), diff --git a/appengine/standard/channel/chatactoe.py b/appengine/standard/channel/chatactoe.py index 2b70b881f92b..b05143254811 100644 --- a/appengine/standard/channel/chatactoe.py +++ b/appengine/standard/channel/chatactoe.py @@ -191,6 +191,7 @@ def get(self): self.redirect(users.create_login_url(self.request.uri)) # [END create_channel_1] + jinja_environment = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) diff --git a/appengine/standard/endpoints/multiapi/main.py b/appengine/standard/endpoints/multiapi/main.py index e50d9ebdec49..c25d9baff36f 100644 --- a/appengine/standard/endpoints/multiapi/main.py +++ b/appengine/standard/endpoints/multiapi/main.py @@ -49,6 +49,7 @@ def bookmark(self, request): # [END books] # [END multiclass] + # [START api_server] api = endpoints.api_server([api_collection]) # [END api_server] diff --git a/appengine/standard/hello_world/main.py b/appengine/standard/hello_world/main.py index 3b6d6597ac8e..c26ad7a80f68 100644 --- a/appengine/standard/hello_world/main.py +++ b/appengine/standard/hello_world/main.py @@ -20,6 +20,7 @@ def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write('Hello, World!') + app = webapp2.WSGIApplication([ ('/', MainPage), ], debug=True) diff --git a/appengine/standard/localtesting/env_vars_test.py b/appengine/standard/localtesting/env_vars_test.py index 019c76296835..31e374def64c 100644 --- a/appengine/standard/localtesting/env_vars_test.py +++ b/appengine/standard/localtesting/env_vars_test.py @@ -36,5 +36,6 @@ def testEnvVars(self): self.assertEqual(os.environ['MY_CONFIG_SETTING'], 'example') # [END env_example] + if __name__ == '__main__': unittest.main() diff --git a/appengine/standard/localtesting/login_test.py b/appengine/standard/localtesting/login_test.py index 2f812516537e..8886b8cb6e62 100644 --- a/appengine/standard/localtesting/login_test.py +++ b/appengine/standard/localtesting/login_test.py @@ -49,5 +49,6 @@ def testLogin(self): # [END test] # [END login_example] + if __name__ == '__main__': unittest.main() diff --git a/appengine/standard/localtesting/mail_test.py b/appengine/standard/localtesting/mail_test.py index ead48353820b..a362aa210eb9 100644 --- a/appengine/standard/localtesting/mail_test.py +++ b/appengine/standard/localtesting/mail_test.py @@ -40,5 +40,6 @@ def testMailSent(self): self.assertEqual('alice@example.com', messages[0].to) # [END mail_example] + if __name__ == '__main__': unittest.main() diff --git a/appengine/standard/localtesting/task_queue_test.py b/appengine/standard/localtesting/task_queue_test.py index 2f9d1e0022e2..2472fe188876 100644 --- a/appengine/standard/localtesting/task_queue_test.py +++ b/appengine/standard/localtesting/task_queue_test.py @@ -85,5 +85,6 @@ def testTaskAddedByDeferred(self): self.assertEqual(result, 3) # [END deferred] + if __name__ == '__main__': unittest.main() diff --git a/appengine/standard/mail/handle_bounced_email.py b/appengine/standard/mail/handle_bounced_email.py index 525ee1288644..4da4e6c8a15b 100644 --- a/appengine/standard/mail/handle_bounced_email.py +++ b/appengine/standard/mail/handle_bounced_email.py @@ -26,4 +26,5 @@ def receive(self, bounce_message): logging.info('Bounce notification: %s', bounce_message.notification) # [END bounce_handler] + app = webapp2.WSGIApplication([LogBounceHandler.mapping()], debug=True) diff --git a/appengine/standard/mail/handle_incoming_email.py b/appengine/standard/mail/handle_incoming_email.py index 2802e903e0f9..44f570951aa7 100644 --- a/appengine/standard/mail/handle_incoming_email.py +++ b/appengine/standard/mail/handle_incoming_email.py @@ -36,6 +36,7 @@ def receive(self, mail_message): plaintext = body.decode() logging.info("Plain text body of length %d.", len(plaintext)) + # [START app] app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True) # [END app] diff --git a/appengine/standard/memcache/best_practices/batch/batch.py b/appengine/standard/memcache/best_practices/batch/batch.py index a1267c8732fd..2f0119c579c8 100644 --- a/appengine/standard/memcache/best_practices/batch/batch.py +++ b/appengine/standard/memcache/best_practices/batch/batch.py @@ -30,6 +30,7 @@ def get(self): self.response.write(tvalues) # [END batch] + app = webapp2.WSGIApplication([ ('/', MainPage), ], debug=True) diff --git a/appengine/standard/modules/main.py b/appengine/standard/modules/main.py index 36e95d042d8f..202daa393469 100644 --- a/appengine/standard/modules/main.py +++ b/appengine/standard/modules/main.py @@ -46,6 +46,7 @@ def get(self): pass # [END access_another_module] + app = webapp2.WSGIApplication([ ('/', GetModuleInfoHandler), ('/access_backend', GetBackendHandler), diff --git a/appengine/standard/ndb/async/app_async.py b/appengine/standard/ndb/async/app_async.py index a9403f1fc39b..c8062cdc4dab 100644 --- a/appengine/standard/ndb/async/app_async.py +++ b/appengine/standard/ndb/async/app_async.py @@ -32,4 +32,5 @@ def get(self): self.response.out.write('Content of the page') future.get_result() + app = webapp2.WSGIApplication([('/', MyRequestHandler)]) diff --git a/appengine/standard/ndb/async/app_sync.py b/appengine/standard/ndb/async/app_sync.py index 690e6b75b251..8cf53f0c15cf 100644 --- a/appengine/standard/ndb/async/app_sync.py +++ b/appengine/standard/ndb/async/app_sync.py @@ -31,4 +31,5 @@ def get(self): self.response.out.write('Content of the page') + app = webapp2.WSGIApplication([('/', MyRequestHandler)]) diff --git a/appengine/standard/xmpp/xmpp.py b/appengine/standard/xmpp/xmpp.py index c28603d6a845..fbc7b95f3752 100644 --- a/appengine/standard/xmpp/xmpp.py +++ b/appengine/standard/xmpp/xmpp.py @@ -93,6 +93,7 @@ def post(self): message.reply("Greetings!") # [END chat] + app = webapp2.WSGIApplication([ ('/_ah/xmpp/message/chat/', XMPPHandler), ('/_ah/xmpp/subscribe', SubscribeHandler), diff --git a/bigquery/api/list_datasets_projects.py b/bigquery/api/list_datasets_projects.py index f13b21016c56..9f214a24930f 100755 --- a/bigquery/api/list_datasets_projects.py +++ b/bigquery/api/list_datasets_projects.py @@ -67,6 +67,7 @@ def main(project_id): list_datasets(bigquery, project_id) list_projects(bigquery) + if __name__ == '__main__': parser = argparse.ArgumentParser( description=__doc__, diff --git a/bigquery/api/load_data_by_post.py b/bigquery/api/load_data_by_post.py index 63e49819e074..caa289339c22 100755 --- a/bigquery/api/load_data_by_post.py +++ b/bigquery/api/load_data_by_post.py @@ -110,6 +110,7 @@ def main(project_id, dataset_id, table_name, schema_path, data_path): table_name) # [END main] + if __name__ == '__main__': parser = argparse.ArgumentParser( description=__doc__, diff --git a/dataproc/list_clusters.py b/dataproc/list_clusters.py index e08ee889ab6e..38e6dd272743 100644 --- a/dataproc/list_clusters.py +++ b/dataproc/list_clusters.py @@ -47,6 +47,7 @@ def main(project_id, zone): result = list_clusters(dataproc, project_id) print(result) + if __name__ == '__main__': parser = argparse.ArgumentParser( description=__doc__, diff --git a/datastore/cloud-client/snippets.py b/datastore/cloud-client/snippets.py index 69e5e87d2a69..ad9bed360f4f 100644 --- a/datastore/cloud-client/snippets.py +++ b/datastore/cloud-client/snippets.py @@ -365,9 +365,9 @@ def get_one_page_of_tasks(cursor=None): page = next(query_iter.pages) tasks = list(page) - next_cusor = query_iter.next_page_token + next_cursor = query_iter.next_page_token - return tasks, next_cusor + return tasks, next_cursor # [END cursor_paging] page_one, cursor_one = get_one_page_of_tasks() diff --git a/error_reporting/main.py b/error_reporting/main.py index 8ed8d5e99418..45208c913ac5 100644 --- a/error_reporting/main.py +++ b/error_reporting/main.py @@ -37,5 +37,6 @@ def report(ex): report(traceback.format_exc()) # [END error_reporting] + if __name__ == '__main__': simulate_error() diff --git a/scripts/auto_link_to_docs.py b/scripts/auto_link_to_docs.py index 5725a77bc078..68f4188d345d 100755 --- a/scripts/auto_link_to_docs.py +++ b/scripts/auto_link_to_docs.py @@ -141,5 +141,6 @@ def main(): for readme, docs in readmes_to_docs.iteritems(): update_readme(readme, docs) + if __name__ == '__main__': main() diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index 469c53ff52c1..c32ce79bddf4 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -61,5 +61,6 @@ def main(): with io.open(destination, 'w') as f: f.write(output) + if __name__ == '__main__': main() diff --git a/speech/api-client/transcribe.py b/speech/api-client/transcribe.py index 52a459e98de7..7580c01f6a3c 100644 --- a/speech/api-client/transcribe.py +++ b/speech/api-client/transcribe.py @@ -78,6 +78,7 @@ def main(speech_file): print(json.dumps(response)) # [END send_request] + # [START run_application] if __name__ == '__main__': parser = argparse.ArgumentParser() diff --git a/storage/transfer_service/aws_request.py b/storage/transfer_service/aws_request.py index 568ba5001a83..aa69c78d3cad 100644 --- a/storage/transfer_service/aws_request.py +++ b/storage/transfer_service/aws_request.py @@ -81,6 +81,7 @@ def main(description, project_id, day, month, year, hours, minutes, json.dumps(result, indent=4))) # [END main] + if __name__ == '__main__': parser = argparse.ArgumentParser( description=__doc__, diff --git a/storage/transfer_service/nearline_request.py b/storage/transfer_service/nearline_request.py index adfb485158cd..093cb5e01176 100644 --- a/storage/transfer_service/nearline_request.py +++ b/storage/transfer_service/nearline_request.py @@ -78,6 +78,7 @@ def main(description, project_id, day, month, year, hours, minutes, json.dumps(result, indent=4))) # [END main] + if __name__ == '__main__': parser = argparse.ArgumentParser( description=__doc__, diff --git a/storage/transfer_service/transfer_check.py b/storage/transfer_service/transfer_check.py index 9ff40af741d4..d37b0cf8a10d 100644 --- a/storage/transfer_service/transfer_check.py +++ b/storage/transfer_service/transfer_check.py @@ -50,6 +50,7 @@ def main(project_id, job_name): json.dumps(result, indent=4, sort_keys=True))) # [END main] + if __name__ == '__main__': parser = argparse.ArgumentParser( description=__doc__, diff --git a/vision/api/label/label.py b/vision/api/label/label.py index b7aed97717a0..bbea1f89ab05 100755 --- a/vision/api/label/label.py +++ b/vision/api/label/label.py @@ -64,6 +64,7 @@ def main(photo_file): print('Found label: %s for %s' % (label, photo_file)) # [END parse_response] + # [START run_application] if __name__ == '__main__': parser = argparse.ArgumentParser() From 49405dfa28c1e98c458b02998ddb8f1754017417 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 13:44:25 -0800 Subject: [PATCH 11/13] Vision quickstart no longer fails on Py3 Change-Id: Iab5bd07b405cf57fa7407efcfa188d1320e5f867 --- vision/cloud-client/quickstart_test.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/vision/cloud-client/quickstart_test.py b/vision/cloud-client/quickstart_test.py index abdc4045f528..d483d4131f7f 100644 --- a/vision/cloud-client/quickstart_test.py +++ b/vision/cloud-client/quickstart_test.py @@ -12,17 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest -import six - import quickstart -@pytest.mark.xfail( - six.PY3, - strict=True, - reason='https://github.com/GoogleCloudPlatform/google-cloud-python/issues' - '/2525') def test_quickstart(capsys): quickstart.run_quickstart() out, _ = capsys.readouterr() From ce4c736afe5598e773adc4433813a4e835049315 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 14:02:16 -0800 Subject: [PATCH 12/13] Address review comment. Change-Id: I33997d42c6202c7f916bcebd4c5a9499392ac4db --- bigquery/cloud-client/snippets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery/cloud-client/snippets.py b/bigquery/cloud-client/snippets.py index 61d498223033..b02ac8ce61fb 100644 --- a/bigquery/cloud-client/snippets.py +++ b/bigquery/cloud-client/snippets.py @@ -128,7 +128,7 @@ def list_rows(dataset_name, table_name, project=None): # Load at most 25 results. You can change the max_results argument to load # more rows from BigQuery, but note that this can take some time. It's # preferred to use a query. - rows = table.fetch_data(max_results=25) + rows = list(table.fetch_data(max_results=25)) # Use format to create a simple table. format_string = '{!s:<16} ' * len(table.schema) From ffdf1caac7a7be2f4162bbc04fe4c008212f2409 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 15 Nov 2016 14:10:38 -0800 Subject: [PATCH 13/13] Fix bigquery installed app sample Change-Id: I9609daebbd2bfd62706193e80fde245bd1ae2566 --- nox.py | 2 +- scripts/travis.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nox.py b/nox.py index 0824c0f7b011..9fff74bac24e 100644 --- a/nox.py +++ b/nox.py @@ -173,7 +173,7 @@ def run_tests_in_sesssion( pytest_args = COMMON_PYTEST_ARGS[:] - if skip_flaky: + if skip_flaky or True: pytest_args.append('-m not slow and not flaky') for sample in sample_directories: diff --git a/scripts/travis.sh b/scripts/travis.sh index 2124f4e7307d..bf7015cf4c13 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -5,6 +5,7 @@ if [[ $TRAVIS_SECURE_ENV_VARS == "true" ]]; then scripts/decrypt-secrets.sh "$SECRETS_PASSWORD" source ${TRAVIS_BUILD_DIR}/testing/test-env.sh; export GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/service-account.json + export GOOGLE_CLIENT_SECRETS=${TRAVIS_BUILD_DIR}/testing/client-secrets.json nox --stop-on-first-error -s lint travis; else # only run lint on external PRs