Skip to content

Commit 3d145e9

Browse files
committed
Get information for multiple Python interpreters
1 parent 2d0ec1c commit 3d145e9

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

osg-system-profiler

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
#!/bin/bash -p
22
# ^ -p protects us from shellshock
33

4-
# pick a python
5-
if command -v python >/dev/null 2>&1; then
6-
python=python
7-
elif command -v python3 >/dev/null 2>&1; then
8-
python=python3
9-
elif command -v python2 >/dev/null 2>&1; then
10-
python=python2
11-
elif test -x /usr/libexec/platform-python; then
12-
python=/usr/libexec/platform-python
13-
else
14-
echo >&2 "Can't find Python"
15-
fi
16-
17-
184
realdir ()
195
{
206
# print the canonical path of a directory, resolving symlinks in
@@ -138,6 +124,15 @@ message() {
138124
echo "$@" >&3
139125
}
140126

127+
python_info () {
128+
local python=$1
129+
$python -c "import sys; print('Version: ' + sys.version)"
130+
$python -c "import sys; print('Executable: ' + sys.executable)"
131+
$python -c "import sys; print('Prefix: ' + sys.prefix)"
132+
$python -c 'import platform; print("Architecture: " + str(platform.architecture()))'
133+
$python -c "import sys; print('Search paths: ' + str(sys.path))"
134+
}
135+
141136
dir=`pwd`
142137

143138
if [ ! -w $dir ]; then
@@ -231,12 +226,12 @@ ps -u xrootd u
231226
echo ""
232227

233228
echo "***** Python information:"
234-
$python -c "import sys; print('Version: ' + sys.version)"
235-
$python -c "import sys; print('Executable: ' + sys.executable)"
236-
$python -c "import sys; print('Prefix: ' + sys.prefix)"
237-
$python -c 'import platform; print("Architecture: " + str(platform.architecture()))'
238-
$python -c "import sys; print('Search paths: ' + str(sys.path))"
239-
echo ""
229+
230+
for python in "$(command -v python)" "$(command -v python2)" "$(command -v python3)" "/usr/libexec/platform-python"; do
231+
if [[ -n $python && -x $python ]]; then
232+
python_info "$python"
233+
fi
234+
done
240235

241236
run_cmd openssl version
242237

0 commit comments

Comments
 (0)