diff --git a/appengine/flexible/analytics/requirements.txt b/appengine/flexible/analytics/requirements.txt index bbdb73b006d..620a68c926f 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/main.py b/appengine/flexible/datastore/main.py index bd19a0de9b9..3130edd53ff 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 diff --git a/appengine/flexible/datastore/requirements.txt b/appengine/flexible/datastore/requirements.txt index e772482ea7c..16bdd7e8315 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 45699fbc037..35ee5939e55 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/hello_world/main.py b/appengine/flexible/hello_world/main.py index ae08dcdfa6e..97eb37d83a2 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/kinto/requirements.txt b/appengine/flexible/kinto/requirements.txt index 9108bb2bcda..95fe80eefdb 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 bbdb73b006d..620a68c926f 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 cb0120b9f8c..e05fc6545c3 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 bbdb73b006d..620a68c926f 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 db7208b11cd..f19f1bbd97c 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 db7208b11cd..f19f1bbd97c 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/numpy/main.py b/appengine/flexible/numpy/main.py index cf6ba319f3e..77f04de8a2c 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/flexible/pubsub/requirements.txt b/appengine/flexible/pubsub/requirements.txt index c297d66713d..fb59bbcc3ad 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 b8148ab66bb..597a0e256f8 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 a0ffd863192..adaac404f1f 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 50bd894d3b5..c545dbd8b71 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/app_identity/asserting/main.py b/appengine/standard/app_identity/asserting/main.py index d0c216b5db0..00d76e7e097 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 f7c25f51afb..68705ccd134 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 8059336a4af..06257a17782 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 1709d4a962b..7a1d7be5928 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 2b70b881f92..b0514325481 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 e50d9ebdec4..c25d9baff36 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/firebase/firetactoe/requirements.txt b/appengine/standard/firebase/firetactoe/requirements.txt index 535f170aac2..1fc6a2a59f7 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/hello_world/main.py b/appengine/standard/hello_world/main.py index 3b6d6597ac8..c26ad7a80f6 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 019c7629683..31e374def64 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 2f812516537..8886b8cb6e6 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 ead48353820..a362aa210eb 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 2f9d1e0022e..2472fe18887 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 525ee128864..4da4e6c8a15 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 2802e903e0f..44f570951aa 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/mailjet/requirements.txt b/appengine/standard/mailjet/requirements.txt index 8e3e8a598d0..705ff274bc3 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/memcache/best_practices/batch/batch.py b/appengine/standard/memcache/best_practices/batch/batch.py index a1267c8732f..2f0119c579c 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 36e95d042d8..202daa39346 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 a9403f1fc39..c8062cdc4da 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 690e6b75b25..8cf53f0c15c 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/sendgrid/requirements.txt b/appengine/standard/sendgrid/requirements.txt index de599997047..51864ac14c7 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 50bd894d3b5..c545dbd8b71 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/appengine/standard/xmpp/xmpp.py b/appengine/standard/xmpp/xmpp.py index c28603d6a84..fbc7b95f375 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 f13b21016c5..9f214a24930 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 63e49819e07..caa289339c2 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/bigquery/cloud-client/requirements.txt b/bigquery/cloud-client/requirements.txt index 11a30326493..d9f269ca7b6 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/cloud-client/snippets.py b/bigquery/cloud-client/snippets.py index f7ab3373105..b02ac8ce61f 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 = list(table.fetch_data(max_results=25)) # Use format to create a simple table. format_string = '{!s:<16} ' * len(table.schema) diff --git a/bigquery/dml/requirements.txt b/bigquery/dml/requirements.txt index 289896af148..d50a20abea4 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 faf739f846d..2a416a31f8f 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 ccc49e93cab..29dc975fb3d 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 b6f2e0128be..7242fd505c3 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 e8591f35156..f5aa404ba7f 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 466103081b6..b37f3801047 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 217aa31c80b..d8e12de0fb8 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/list_clusters.py b/dataproc/list_clusters.py index e08ee889ab6..38e6dd27274 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/dataproc/requirements.txt b/dataproc/requirements.txt index 6ac114bc48d..d291ebf7aa8 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 ccc49e93cab..29dc975fb3d 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/datastore/cloud-client/snippets.py b/datastore/cloud-client/snippets.py index ed6c62da79e..ad9bed360f4 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_cursor = query_iter.next_page_token + + return tasks, next_cursor # [END cursor_paging] page_one, cursor_one = get_one_page_of_tasks() diff --git a/dns/api/main.py b/dns/api/main.py index 2ed3d61d7c3..f18517d2dea 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 21b02ae2e27..be6dfef78b5 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() diff --git a/dns/api/requirements.txt b/dns/api/requirements.txt index ed5da71cc16..3138fa7601e 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 45699fbc037..35ee5939e55 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/error_reporting/main.py b/error_reporting/main.py index 8ed8d5e9941..45208c913ac 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/language/movie_nl/requirements.txt b/language/movie_nl/requirements.txt index 7a0de85468f..f552f7468eb 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/export.py b/logging/cloud-client/export.py index 20367c274b2..f8c1f0c5f95 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/requirements.txt b/logging/cloud-client/requirements.txt index 303f67c091c..ce5d85c60e7 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/logging/cloud-client/snippets.py b/logging/cloud-client/snippets.py index 0280cfbe406..8a31066fa3b 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)) diff --git a/nox.py b/nox.py index 664540e5710..9fff74bac24 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) @@ -172,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: @@ -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()): diff --git a/pubsub/cloud-client/publisher.py b/pubsub/cloud-client/publisher.py index d527b54cb1c..46504756056 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/requirements.txt b/pubsub/cloud-client/requirements.txt index 7aa8ce1fbd1..f2fc2b4a2aa 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/pubsub/cloud-client/subscriber.py b/pubsub/cloud-client/subscriber.py index b4fdd95738d..9a564496e42 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) diff --git a/scripts/auto_link_to_docs.py b/scripts/auto_link_to_docs.py index 5725a77bc07..68f4188d345 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 469c53ff52c..c32ce79bddf 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/scripts/travis.sh b/scripts/travis.sh index 2124f4e7307..bf7015cf4c1 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 diff --git a/speech/api-client/transcribe.py b/speech/api-client/transcribe.py index 52a459e98de..7580c01f6a3 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/speech/grpc/requirements.txt b/speech/grpc/requirements.txt index 582065ec142..0f312db88ae 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/encryption.py b/storage/cloud-client/encryption.py index d15be17c2af..782e70b5c53 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 28fa5e3b895..926be643c59 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 diff --git a/storage/cloud-client/requirements.txt b/storage/cloud-client/requirements.txt index 303fed123d8..025b3c37ad3 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/storage/transfer_service/aws_request.py b/storage/transfer_service/aws_request.py index 568ba5001a8..aa69c78d3ca 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 adfb485158c..093cb5e0117 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 9ff40af741d..d37b0cf8a10 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/testing/requirements-dev.in b/testing/requirements-dev.in index 03ad62ab93e..46e415ffcc7 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 d0118964875..5b1c7e629d0 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/api/label/label.py b/vision/api/label/label.py index b7aed97717a..bbea1f89ab0 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() diff --git a/vision/cloud-client/quickstart_test.py b/vision/cloud-client/quickstart_test.py index abdc4045f52..d483d4131f7 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() diff --git a/vision/cloud-client/requirements.txt b/vision/cloud-client/requirements.txt index f549e6d149e..c2a564db596 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