diff --git a/.kokoro/docker/Dockerfile b/.kokoro/docker/Dockerfile index 6b6c19f1..accdd0bf 100644 --- a/.kokoro/docker/Dockerfile +++ b/.kokoro/docker/Dockerfile @@ -15,8 +15,8 @@ FROM gcr.io/cloud-devrel-kokoro-resources/python-base:latest # Install libraries needed by third-party python packages that we depend on. -RUN apt update \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ graphviz \ libcurl4-openssl-dev \ libffi-dev \ @@ -30,32 +30,19 @@ RUN apt update \ libxml2-dev \ libxslt1-dev \ openssl \ - portaudio19-dev \ - python-pyaudio \ zlib1g-dev \ - && apt clean + && apt-get clean -###################### Install python 3.7.12 - -# Download python 3.7.12 -RUN wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz - -# Extract files -RUN tar -xvf Python-3.7.12.tgz - -# Install python 3.7.12 -RUN ./Python-3.7.12/configure --enable-optimizations -RUN make altinstall ###################### Check python version -RUN python --version -RUN which python +RUN python3 --version +RUN which python3 # Setup Cloud SDK -ENV CLOUD_SDK_VERSION 369.0.0 +ENV CLOUD_SDK_VERSION 489.0.0 # Use system python for cloud sdk. -ENV CLOUDSDK_PYTHON /usr/bin/python +ENV CLOUDSDK_PYTHON python3.12 RUN wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz RUN tar xzf google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz RUN /google-cloud-sdk/install.sh diff --git a/authenticating-users/requirements.txt b/authenticating-users/requirements.txt index 9725073e..0d4a3c36 100644 --- a/authenticating-users/requirements.txt +++ b/authenticating-users/requirements.txt @@ -1,6 +1,6 @@ # [START getting_started_requirements] -Flask==2.2.2 -cryptography==39.0.0 +Flask==2.2.5 +cryptography==41.0.2 python-jose[cryptography]==3.3.0 -requests==2.28.2 +requests==2.31.0 # [END getting_started_requirements] diff --git a/background/app/app.yaml b/background/app/app.yaml index fb63451a..02c0651c 100644 --- a/background/app/app.yaml +++ b/background/app/app.yaml @@ -13,5 +13,5 @@ # limitations under the License. # [START getting_started_background_config] -runtime: python37 +runtime: python312 # [END getting_started_background_config] diff --git a/background/app/main.py b/background/app/main.py index 5474d54c..fad93d46 100644 --- a/background/app/main.py +++ b/background/app/main.py @@ -21,8 +21,8 @@ import os from flask import Flask, redirect, render_template, request -from google.cloud import firestore -from google.cloud import pubsub +from google.cloud import firestore, pubsub +from markupsafe import escape app = Flask(__name__) @@ -61,15 +61,13 @@ def translate(): language (form field 'lang'), by sending a PubSub message to a topic. """ source_string = request.form.get("v", "") - to_language = request.form.get("lang", "") + to_language = escape(request.form.get("lang", "")) if source_string == "": - error_message = "Empty value" - return error_message, 400 + return "Invalid request, you must provide a value.", 400 if to_language not in ACCEPTABLE_LANGUAGES: - error_message = "Unsupported language: {}".format(to_language) - return error_message, 400 + return f"Unsupported language: {to_language}", 400 message = { "Original": source_string, @@ -78,11 +76,11 @@ def translate(): "OriginalLanguage": "", } - topic_name = "projects/{}/topics/{}".format( - os.getenv("GOOGLE_CLOUD_PROJECT"), "translate" + topic_name = ( + f"projects/{os.getenv('GOOGLE_CLOUD_PROJECT')}/topics/translate" ) publisher.publish( - topic=topic_name, data=json.dumps(message).encode("utf8") + topic=topic_name, data=json.dumps(message).encode("utf-8") ) return redirect("/") diff --git a/background/app/main_test.py b/background/app/main_test.py index f3bf28c2..41b529d3 100644 --- a/background/app/main_test.py +++ b/background/app/main_test.py @@ -16,8 +16,7 @@ import uuid import google.auth -from google.cloud import firestore -from google.cloud import pubsub +from google.cloud import firestore, pubsub, storage import main import pytest @@ -39,7 +38,10 @@ def clear_collection(collection): for doc in collection.stream(): doc.reference.delete() + bucket_name = 'system-test-bucket' client = firestore.Client() + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) translations = client.collection("translations") clear_collection(translations) translations.add( @@ -51,6 +53,7 @@ def clear_collection(collection): }, document_id="test translation", ) + assert bucket in locals() yield client diff --git a/background/app/requirements.txt b/background/app/requirements.txt index ebd90391..f70d16b7 100644 --- a/background/app/requirements.txt +++ b/background/app/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-firestore==2.9.0 -google-cloud-pubsub==2.14.0 -flask==2.2.2 +google-cloud-firestore==2.18.0 +google-cloud-pubsub==2.23.0 +flask==3.0.3 diff --git a/background/function/requirements.txt b/background/function/requirements.txt index 44dffc3c..b8e6aaad 100644 --- a/background/function/requirements.txt +++ b/background/function/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-translate==3.10.1 -google-cloud-firestore==2.9.0 +google-cloud-translate==3.11.1 +google-cloud-firestore==2.11.1 diff --git a/bookshelf/requirements.txt b/bookshelf/requirements.txt index f1cbf765..27d3d4fe 100644 --- a/bookshelf/requirements.txt +++ b/bookshelf/requirements.txt @@ -1,7 +1,7 @@ -Flask==2.2.2 -google-cloud-firestore==2.9.0 -google-cloud-storage==2.7.0 -google-cloud-error-reporting==1.8.0 -google-cloud-logging==3.4.0 +Flask==2.2.5 +google-cloud-firestore==2.11.1 +google-cloud-storage==2.9.0 +google-cloud-error-reporting==1.9.1 +google-cloud-logging==3.5.0 gunicorn==20.1.0 six==1.16.0 diff --git a/gce/requirements.txt b/gce/requirements.txt index a39a519c..b655465f 100644 --- a/gce/requirements.txt +++ b/gce/requirements.txt @@ -1,3 +1,3 @@ -flask==2.2.2 +flask==2.2.5 honcho==1.1.0 gunicorn==20.1.0 diff --git a/noxfile.py b/noxfile.py index 68fb5a37..8f5a921c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -55,7 +55,7 @@ def run_test(session, dir): success_codes=[0, 5]) -@nox.session(python="3.7") +@nox.session(python="3.12") @nox.parametrize('dir', DIRS) def run_tests(session, dir=None): """Run all tests for all directories (slow!)""" diff --git a/optional-kubernetes-engine/Makefile b/optional-kubernetes-engine/Makefile index f275ddf4..4c1cbf3e 100644 --- a/optional-kubernetes-engine/Makefile +++ b/optional-kubernetes-engine/Makefile @@ -12,8 +12,8 @@ create-cluster: .PHONY: create-bucket create-bucket: - gsutil mb gs://$(GCLOUD_PROJECT) - gsutil defacl set public-read gs://$(GCLOUD_PROJECT) + gcloud storage buckets create gs://$(GCLOUD_PROJECT) + gcloud storage buckets update gs://$(GCLOUD_PROJECT) --predefined-default-object-acl=public-read .PHONY: build build: diff --git a/optional-kubernetes-engine/README.md b/optional-kubernetes-engine/README.md index e3c17236..9acb98b4 100644 --- a/optional-kubernetes-engine/README.md +++ b/optional-kubernetes-engine/README.md @@ -36,8 +36,8 @@ Alternatively, you can use make: The bookshelf application uses [Google Cloud Storage](https://cloud.google.com/storage) to store image files. Create a bucket for your project: - gsutil mb gs:// - gsutil defacl set public-read gs:// + gcloud storage buckets create gs:// + gcloud storage buckets update gs:// --predefined-default-object-acl=public-read Alternatively, you can use make: diff --git a/optional-kubernetes-engine/config.py b/optional-kubernetes-engine/config.py index 0fd601ed..7da9b4cc 100644 --- a/optional-kubernetes-engine/config.py +++ b/optional-kubernetes-engine/config.py @@ -78,12 +78,12 @@ # Typically, you'll name your bucket the same as your project. To create a # bucket: # -# $ gsutil mb gs:// +# $ gcloud storage buckets create gs:// # # You also need to make sure that the default ACL is set to public-read, # otherwise users will not be able to see their upload images: # -# $ gsutil defacl set public-read gs:// +# $ gcloud storage buckets update --predefined-default-object-acl=public-read gs:// # # You can adjust the max content length and allow extensions settings to allow # larger or more varied file types if desired. diff --git a/requirements.txt b/requirements.txt index 930cfb5d..0fd66f54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ flake8===5.0.4; python_version < '3.8' flake8==6.0.0; python_version >= '3.8' -pytest==7.2.1 -nox==2022.11.21 -requests==2.28.2 +pytest==7.3.1 +nox==2023.4.22 +requests==2.31.0 diff --git a/sessions/requirements.txt b/sessions/requirements.txt index 09ff17a0..e0e267b5 100644 --- a/sessions/requirements.txt +++ b/sessions/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-firestore==2.9.0 -flask==2.2.2 +google-cloud-firestore==2.11.1 +flask==2.2.5