Skip to content

Commit b97b6c9

Browse files
kchertenkoparthea
andauthored
fix: add an error message on user import data script in case of any errors. (#288)
Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 6e8dabb commit b97b6c9

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

generated_samples/interactive-tutorials/user_import_data_to_catalog.sh

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,31 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# set the service account key as a GOOGLE_APPLICATION_CREDENTIALS
18-
export GOOGLE_APPLICATION_CREDENTIALS=~/key.json
17+
{
18+
# set the service account key as a GOOGLE_APPLICATION_CREDENTIALS
19+
export GOOGLE_APPLICATION_CREDENTIALS=~/key.json
1920

20-
# activate the python virtual env
21-
source ~/cloudshell_open/myenv/bin/activate
21+
# activate the python virtual env
22+
source ~/cloudshell_open/myenv/bin/activate
2223

23-
# Create a GCS bucket and upload the product data to the bucket
24-
output=$(python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py)
24+
# Create a GCS bucket and upload the product data to the bucket
25+
output=$(python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py)
2526

26-
# Get the bucket name and store it in the env variable BUCKET_NAME
27-
temp="${output#*The gcs bucket }"
28-
bucket_name="${temp% was created*}"
29-
export BUCKET_NAME=$bucket_name
27+
# Get the bucket name and store it in the env variable BUCKET_NAME
28+
temp="${output#*The gcs bucket }"
29+
bucket_name="${temp% was created*}"
30+
export BUCKET_NAME=$bucket_name
3031

31-
# Import products to the Retail catalog
32-
python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py
33-
34-
echo "====================================="
35-
echo "Your Retail catalog is ready to use!"
36-
echo "====================================="
32+
# Import products to the Retail catalog
33+
python ~/cloudshell_open/python-retail/samples/interactive-tutorials/product/import_products_gcs.py
34+
} && {
35+
# Print success message
36+
echo "====================================="
37+
echo "Your Retail catalog is ready to use!"
38+
echo "====================================="
39+
} || {
40+
# Print error message
41+
echo "====================================="
42+
echo "Your Retail catalog wasn't created! Please fix the errors above!"
43+
echo "====================================="
44+
}

0 commit comments

Comments
 (0)