-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update samples to support latest Google Cloud Python #656
Changes from 9 commits
6351867
d106640
91847ca
1374be3
20d9de9
11575bc
f691fbd
22e3d53
03b27e8
3568981
49405df
ce4c736
ffdf1ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
gunicorn==19.6.0 | ||
requests[security]==2.11.1 | ||
requests[security]==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
|
||
import datetime | ||
import logging | ||
import os | ||
import socket | ||
|
||
from flask import Flask, request | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
gunicorn==19.6.0 | ||
oauth2client==4.0.0 | ||
kinto==4.3.2 | ||
kinto==4.3.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
gunicorn==19.6.0 | ||
requests[security]==2.11.1 | ||
requests[security]==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
gunicorn==19.6.0 | ||
requests[security]==2.11.1 | ||
requests[security]==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
gunicorn==19.6.0 | ||
requests==2.11.1 | ||
requests==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
gunicorn==19.6.0 | ||
requests==2.11.1 | ||
requests==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
sendgrid==3.6.2 | ||
sendgrid==3.6.3 | ||
gunicorn==19.6.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
google-cloud-storage==0.20.0 | ||
google-cloud-storage==0.21.0 | ||
gunicorn==19.6.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
requests==2.11.1 | ||
requests==2.12.0 | ||
requests-toolbelt==0.7.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sendgrid==3.6.2 | ||
sendgrid==3.6.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
requests==2.11.1 | ||
requests==2.12.0 | ||
requests-toolbelt==0.7.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-bigquery==0.20.0 | ||
google-cloud-bigquery==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-bigtable==0.20.0 | ||
google-cloud-bigtable==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-datastore==0.20.1 | ||
google-cloud-datastore==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
requests==2.11.1 | ||
requests==2.12.0 | ||
google-api-python-client==1.5.5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
cryptography==1.5.3 | ||
requests==2.11.1 | ||
requests==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
requests==2.11.1 | ||
requests==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Flask==0.11.1 | ||
requests==2.11.1 | ||
requests==2.12.0 | ||
sleekxmpp==1.3.1 | ||
six==1.10.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
google-api-python-client==1.5.5 | ||
google-cloud==0.20.0 | ||
google-cloud==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-datastore==0.20.1 | ||
google-cloud-datastore==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
|
||
return tasks, next_cusor | ||
# [END cursor_paging] | ||
|
||
page_one, cursor_one = get_one_page_of_tasks() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-dns==0.20.0 | ||
google-cloud-dns==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
google-api-python-client==1.5.5 | ||
requests==2.11.1 | ||
requests==2.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-logging==0.20.0 | ||
google-cloud-logging==0.21.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do this more succinctly:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like it, but it's almost too clever. I'm going to leave as-is for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't care either way but don't think it's too clever, a bit more English-esque if anything. |
||
|
||
requirements = [ | ||
mark_if_necessary(requirement) for requirement in requirements] | ||
|
||
requirements = [ | ||
requirement for requirement in requirements if not | ||
is_ignored(requirement)] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could put this conditional in the previous comprehension, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather not. |
||
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()): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-pubsub==0.20.0 | ||
google-cloud-pubsub==0.21.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may prefer to just consume the iterator right here:
There is too much suspense between this and the
for row in rows
(when the request(s) actually get made)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, done.