Skip to content

Commit ad68679

Browse files
authored
Merge branch 'master' into fix-getting-started
2 parents 6a6141f + 27c5c18 commit ad68679

File tree

131 files changed

+2049
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2049
-625
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Code owners file.
22
# This file controls who is tagged for review for any given pull request.
33

4+
# The python-samples-owners team is the default owner for anything not
5+
# explicitly taken by someone else.
6+
* @GoogleCloudPlatform/python-samples-owners
7+
48
# Alix Hamilton is the primary maintainer of the BigQuery samples.
59
bigquery/* @alixhami
610

.github/blunderbuss.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
assign_issues:
2+
- busunkim96
3+
- dmahugh
4+
- kurtisvg
5+
- leahecole
6+
assign_prs:
7+
- busunkim96
8+
- dmahugh
9+
- kurtisvg
10+
- leahecole

appengine/flexible/scipy/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Flask==1.1.1
22
gunicorn==19.9.0
33
numpy==1.17.2
44
scipy==1.2.0
5-
Pillow==6.1.0
5+
pillow==6.2.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Flask==1.1.1
22
gunicorn==19.9.0
3-
google-cloud-tasks==1.2.1
3+
google-cloud-tasks==1.3.0
44
googleapis-common-protos==1.6.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
runtime: python37
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START gae_python37_app]
16+
from flask import Flask, request
17+
18+
# Enable cloud debugger
19+
try:
20+
import googleclouddebugger
21+
googleclouddebugger.enable()
22+
except ImportError:
23+
pass
24+
25+
# Adjust logging level to INFO
26+
import logging
27+
logging.basicConfig(level=logging.INFO)
28+
29+
# If `entrypoint` is not defined in app.yaml, App Engine will look for an app
30+
# called `app` in `main.py`.
31+
app = Flask(__name__)
32+
33+
34+
# There is a bug in the code.
35+
class StringProcessor():
36+
def __init__(self, string):
37+
self._string = string
38+
39+
def Reverse(self):
40+
if self._string is '':
41+
return ''
42+
43+
chars = [c for c in self._string]
44+
left = 0
45+
right = len(chars) - 1
46+
while True:
47+
tmp = chars[left]
48+
chars[left] = chars[right]
49+
chars[right] = tmp
50+
if left >= right:
51+
break
52+
left += 1
53+
right -= 1
54+
55+
return ''.join(chars)
56+
57+
58+
@app.route('/reverse_string', methods=['GET'])
59+
def ReverseString():
60+
try:
61+
s = str(request.args.get('string'))
62+
except Exception as e:
63+
print(e)
64+
return 'Not a valid string!'
65+
66+
current = StringProcessor(s).Reverse()
67+
expected = s[::-1]
68+
return '''
69+
<table>
70+
<tr><th>Program Output:</th><th>{}</th></tr>
71+
<tr><th>Correct Output:</th><th>{}</th><tr>
72+
</table>
73+
'''.format(current, expected)
74+
75+
76+
77+
@app.route('/')
78+
def Hello():
79+
"""Return a friendly HTTP greeting."""
80+
return '''
81+
Hello! Enter a string to reverse it.
82+
<form method="get" action="reverse_string">
83+
<p><input type=text name=string value="abcd">
84+
<p><input type=submit>
85+
</form>
86+
'''
87+
88+
89+
if __name__ == '__main__':
90+
# This is used when running locally only. When deploying to Google App
91+
# Engine, a webserver process such as Gunicorn will serve the app. This
92+
# can be configured by adding an `entrypoint` to app.yaml.
93+
app.run(host='127.0.0.1', port=8080, debug=True)
94+
# [END gae_python37_app]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask==1.1.1
2+
google-python-cloud-debugger
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Django==2.2.5
1+
Django==2.1.14
22
PyMySQL==0.9.3

asset/cloud-client/quickstart_createfeed_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import quickstart_createfeed
2222
import quickstart_deletefeed
2323
from google.cloud import resource_manager
24+
from google.cloud import pubsub_v1
2425

2526
json_data = open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]).read()
2627
data = json.loads(json_data)
@@ -34,6 +35,9 @@ def test_create_feed(capsys):
3435
client = resource_manager.Client()
3536
project_number = client.fetch_project(PROJECT).number
3637
full_topic_name = "projects/{}/topics/{}".format(PROJECT, TOPIC)
38+
publisher = pubsub_v1.PublisherClient()
39+
topic_path = publisher.topic_path(PROJECT, TOPIC)
40+
publisher.create_topic(topic_path)
3741
quickstart_createfeed.create_feed(
3842
PROJECT, FEED_ID, [ASSET_NAME, ], full_topic_name)
3943
out, _ = capsys.readouterr()
@@ -42,3 +46,4 @@ def test_create_feed(capsys):
4246
# Clean up, delete the feed
4347
feed_name = "projects/{}/feeds/{}".format(project_number, FEED_ID)
4448
quickstart_deletefeed.delete_feed(feed_name)
49+
publisher.delete_topic(topic_path)

asset/cloud-client/quickstart_deletefeed_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import quickstart_createfeed
2121
import quickstart_deletefeed
2222
from google.cloud import resource_manager
23+
from google.cloud import pubsub_v1
2324

2425
PROJECT = os.environ['GCLOUD_PROJECT']
2526
ASSET_NAME = 'assets-{}'.format(int(time.time()))
@@ -32,6 +33,9 @@ def test_delete_feed(capsys):
3233
project_number = client.fetch_project(PROJECT).number
3334
# First create the feed, which will be deleted later
3435
full_topic_name = "projects/{}/topics/{}".format(PROJECT, TOPIC)
36+
publisher = pubsub_v1.PublisherClient()
37+
topic_path = publisher.topic_path(PROJECT, TOPIC)
38+
publisher.create_topic(topic_path)
3539
quickstart_createfeed.create_feed(
3640
PROJECT, FEED_ID, [ASSET_NAME, ], full_topic_name)
3741

@@ -40,3 +44,4 @@ def test_delete_feed(capsys):
4044

4145
out, _ = capsys.readouterr()
4246
assert "deleted_feed" in out
47+
publisher.delete_topic(topic_path)

0 commit comments

Comments
 (0)