Skip to content

Commit 007565f

Browse files
committed
fix: allow for flexibility in how pyhton is specified
Signed-off-by: Chris Butler <chris.butler@redhat.com>
1 parent c346093 commit 007565f

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

rhdp/wrapper-multicluster.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/usr/bin/env bash
2-
set -e
2+
set -e
3+
4+
# Function to detect available python binary
5+
get_python_cmd() {
6+
if command -v python3 &> /dev/null; then
7+
echo "python3"
8+
elif command -v python &> /dev/null; then
9+
echo "python"
10+
else
11+
echo "ERROR: Neither python3 nor python is available" >&2
12+
exit 1
13+
fi
14+
}
315

416
if [ "$#" -ne 1 ]; then
517
echo "Error: Exactly one argument is required."
@@ -98,7 +110,8 @@ fi
98110
echo "---------------------"
99111
echo "defining both clusters (hub and spoke)"
100112
echo "---------------------"
101-
python rhdp/rhdp-cluster-define.py --multicluster ${AZUREREGION}
113+
PYTHON_CMD=$(get_python_cmd)
114+
$PYTHON_CMD rhdp/rhdp-cluster-define.py --multicluster ${AZUREREGION}
102115
echo "---------------------"
103116
echo "clusters defined"
104117
echo "---------------------"

rhdp/wrapper.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11

22
#!/usr/bin/env bash
3-
set -e
3+
set -e
4+
5+
# Function to detect available python binary
6+
get_python_cmd() {
7+
if command -v python3 &> /dev/null; then
8+
echo "python3"
9+
elif command -v python &> /dev/null; then
10+
echo "python"
11+
else
12+
echo "ERROR: Neither python3 nor python is available" >&2
13+
exit 1
14+
fi
15+
}
416

517
if [ "$#" -ne 1 ]; then
618
echo "Error: Exactly one argument is required."
@@ -100,7 +112,8 @@ fi
100112
echo "---------------------"
101113
echo "defining cluster"
102114
echo "---------------------"
103-
python rhdp/rhdp-cluster-define.py ${AZUREREGION}
115+
PYTHON_CMD=$(get_python_cmd)
116+
$PYTHON_CMD rhdp/rhdp-cluster-define.py ${AZUREREGION}
104117
echo "---------------------"
105118
echo "cluster defined"
106119
echo "---------------------"

0 commit comments

Comments
 (0)