Skip to content

Commit df1ecc6

Browse files
author
Jon Wayne Parrott
committed
Updating to runtime: python, fixing logging, updating packages, and fixing datastore.
1 parent 555dc6a commit df1ecc6

Some content is hidden

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

43 files changed

+161
-530
lines changed

1-hello-world/.dockerignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

1-hello-world/Dockerfile

Lines changed: 0 additions & 41 deletions
This file was deleted.

1-hello-world/app.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# limitations under the License.
1414

1515
# This file specifies your Python application's runtime configuration.
16-
# See https://cloud.google.com/appengine/docs/managed-vms/config for details.
16+
# See https://cloud.google.com/appengine/docs/managed-vms/python/runtime
17+
# for details.
1718

1819
# [START runtime]
19-
runtime: custom
20+
runtime: python
2021
vm: true
21-
# [END runtime]
22+
entrypoint: gunicorn -b :$PORT main:app
2223

23-
# Temporary setting to keep gcloud from uploading the virtualenv
24-
skip_files:
25-
- ^v?env$
24+
runtime_config:
25+
python_version: 3
26+
# [END runtime]

2-structured-data/.dockerignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

2-structured-data/Dockerfile

Lines changed: 0 additions & 39 deletions
This file was deleted.

2-structured-data/app.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
# limitations under the License.
1414

1515
# This file specifies your Python application's runtime configuration.
16-
# See https://cloud.google.com/appengine/docs/managed-vms/config for details.
16+
# See https://cloud.google.com/appengine/docs/managed-vms/python/runtime
17+
# for details.
1718

18-
runtime: custom
19+
runtime: python
1920
vm: true
21+
entrypoint: gunicorn -b :$PORT main:app
2022

21-
# Temporary setting to keep gcloud from uploading the virtualenv
22-
skip_files:
23-
- ^v?env$
23+
runtime_config:
24+
python_version: 3

2-structured-data/bookshelf/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import logging
16+
1517
from flask import current_app, Flask, redirect, url_for
1618

1719

@@ -25,6 +27,10 @@ def create_app(config, debug=False, testing=False, config_overrides=None):
2527
if config_overrides:
2628
app.config.update(config_overrides)
2729

30+
# Configure logging
31+
if not app.testing:
32+
logging.basicConfig(level=logging.INFO)
33+
2834
# Setup the data model.
2935
with app.app_context():
3036
model = get_model()
@@ -39,6 +45,16 @@ def create_app(config, debug=False, testing=False, config_overrides=None):
3945
def index():
4046
return redirect(url_for('crud.list'))
4147

48+
# Add an error handler. This is useful for debugging the live application,
49+
# however, you should disable the output of the exception for production
50+
# applications.
51+
@app.errorhandler(500)
52+
def server_error(e):
53+
return """
54+
An internal error occurred: <pre>{}</pre>
55+
See logs for full stacktrace.
56+
""".format(e), 500
57+
4258
return app
4359

4460

2-structured-data/bookshelf/model_datastore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def init_app(app):
2424

2525

2626
def get_client():
27-
return datastore.Client(
28-
dataset_id=current_app.config['DATASTORE_DATASET_ID'])
27+
return datastore.Client(current_app.config['PROJECT_ID'])
2928

3029

3130
# [START from_datastore]

2-structured-data/config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
# https://console.developers.google.com
3333
PROJECT_ID = 'your-project-id'
3434

35-
# Cloud Datastore dataset id, this is the same as your project id.
36-
DATASTORE_DATASET_ID = PROJECT_ID
37-
3835
# SQLAlchemy configuration
3936
# Replace user, pass, host, and database with the respective values of your
4037
# Cloud SQL instance.

3-binary-data/.dockerignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

3-binary-data/Dockerfile

Lines changed: 0 additions & 39 deletions
This file was deleted.

3-binary-data/app.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
# This file specifies your Python application's runtime configuration.
1616
# See https://cloud.google.com/appengine/docs/managed-vms/config for details.
1717

18-
runtime: custom
18+
runtime: python
1919
vm: true
20+
entrypoint: gunicorn -b :$PORT main:app
21+
22+
runtime_config:
23+
python_version: 3
2024

21-
# Temporary setting to keep gcloud from uploading the virtualenv
22-
skip_files:
23-
- ^v?env$

3-binary-data/bookshelf/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import logging
16+
1517
from flask import current_app, Flask, redirect, url_for
1618

1719

@@ -25,6 +27,10 @@ def create_app(config, debug=False, testing=False, config_overrides=None):
2527
if config_overrides:
2628
app.config.update(config_overrides)
2729

30+
# Configure logging
31+
if not app.testing:
32+
logging.basicConfig(level=logging.INFO)
33+
2834
# Setup the data model.
2935
with app.app_context():
3036
model = get_model()
@@ -39,6 +45,16 @@ def create_app(config, debug=False, testing=False, config_overrides=None):
3945
def index():
4046
return redirect(url_for('crud.list'))
4147

48+
# Add an error handler. This is useful for debugging the live application,
49+
# however, you should disable the output of the exception for production
50+
# applications.
51+
@app.errorhandler(500)
52+
def server_error(e):
53+
return """
54+
An internal error occurred: <pre>{}</pre>
55+
See logs for full stacktrace.
56+
""".format(e), 500
57+
4258
return app
4359

4460

3-binary-data/bookshelf/model_datastore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def init_app(app):
2424

2525

2626
def get_client():
27-
return datastore.Client(
28-
dataset_id=current_app.config['DATASTORE_DATASET_ID'])
27+
return datastore.Client(current_app.config['PROJECT_ID'])
2928

3029

3130
def from_datastore(entity):

3-binary-data/config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
# https://console.developers.google.com
3333
PROJECT_ID = 'your-project-id'
3434

35-
# Cloud Datastore dataset id, this is the same as your project id.
36-
DATASTORE_DATASET_ID = PROJECT_ID
37-
3835
# SQLAlchemy configuration
3936
# Replace user, pass, host, and database with the respective values of your
4037
# Cloud SQL instance.

4-auth/.dockerignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)