From b97b6c9513096c435f0149c762da4a4cee9e3950 Mon Sep 17 00:00:00 2001 From: kchertenko <108395945+kchertenko@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:14:34 +0300 Subject: [PATCH] fix: add an error message on user import data script in case of any errors. (#288) Co-authored-by: Anthonios Partheniou --- .../user_import_data_to_catalog.sh | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/generated_samples/interactive-tutorials/user_import_data_to_catalog.sh b/generated_samples/interactive-tutorials/user_import_data_to_catalog.sh index 0d702a95bee5..7e65f7e23e74 100644 --- a/generated_samples/interactive-tutorials/user_import_data_to_catalog.sh +++ b/generated_samples/interactive-tutorials/user_import_data_to_catalog.sh @@ -14,23 +14,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -# set the service account key as a GOOGLE_APPLICATION_CREDENTIALS -export GOOGLE_APPLICATION_CREDENTIALS=~/key.json +{ + # set the service account key as a GOOGLE_APPLICATION_CREDENTIALS + export GOOGLE_APPLICATION_CREDENTIALS=~/key.json -# activate the python virtual env -source ~/cloudshell_open/myenv/bin/activate + # activate the python virtual env + source ~/cloudshell_open/myenv/bin/activate -# Create a GCS bucket and upload the product data to the bucket -output=$(python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py) + # Create a GCS bucket and upload the product data to the bucket + output=$(python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py) -# Get the bucket name and store it in the env variable BUCKET_NAME -temp="${output#*The gcs bucket }" -bucket_name="${temp% was created*}" -export BUCKET_NAME=$bucket_name + # Get the bucket name and store it in the env variable BUCKET_NAME + temp="${output#*The gcs bucket }" + bucket_name="${temp% was created*}" + export BUCKET_NAME=$bucket_name -# Import products to the Retail catalog -python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py - -echo "=====================================" -echo "Your Retail catalog is ready to use!" -echo "=====================================" \ No newline at end of file + # Import products to the Retail catalog + python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py +} && { + # Print success message + echo "=====================================" + echo "Your Retail catalog is ready to use!" + echo "=====================================" +} || { + # Print error message + echo "=====================================" + echo "Your Retail catalog wasn't created! Please fix the errors above!" + echo "=====================================" +}