Skip to content

Commit

Permalink
Add check about file existence and type
Browse files Browse the repository at this point in the history
  • Loading branch information
dkatzz authored Oct 18, 2024
1 parent 7a7c2b6 commit 62c2d90
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cloud/shared/bin/python_env_setup
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,20 @@ function initialize_python_env() {
# source the activate script (. is more portable between shells than source)
. .venv/bin/activate

# If a certificate file is specified, configure pip to use it
# If a certificate file is specified, perform checks then configure pip to use it
if [[ -n "$cert_file_path" ]]; then
# Check if the file exists and is readable
if [[ ! -r "$cert_file_path" ]]; then
echo "Error: Certificate file '$cert_file_path' does not exist or is not readable."
return 1
fi

# Check the file format is PEM
if ! file "$cert_file_path" | grep -q "PEM certificate"; then
echo "Error: Certificate file '$cert_file_path' is not in the correct format (expected PEM)."
return 1
fi

echo "Setting pip global.cert to $cert_file_path"
pip config set global.cert "$cert_file_path"
fi
Expand Down

0 comments on commit 62c2d90

Please sign in to comment.