-
-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2687 from jimklimov/py-module-relative
NUT-Monitor UI and PyNUT: better support for relative path to module, better detect usable interpreter
- Loading branch information
Showing
3 changed files
with
77 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# a single simple call. | ||
# | ||
# Copyright (C): | ||
# 2022-2023 Jim Klimov <[email protected]> | ||
# 2022-2024 Jim Klimov <[email protected]> | ||
# | ||
# License: GPLv2+ | ||
|
||
|
@@ -14,27 +14,33 @@ | |
PREFER_PY2=true | ||
|
||
# Detect which variant of NUT-Monitor we can run on the local system: | ||
[ -s "$0"-py2gtk2 -a -x "$0"-py2gtk2 ] && PYTHON_PY2GTK2="`head -1 "$0"-py2gtk2 | sed 's,^#!,,'`" || PYTHON_PY2GTK2="" | ||
[ -s "$0"-py3qt5 -a -x "$0"-py3qt5 ] && PYTHON_PY3QT5="`head -1 "$0"-py3qt5 | sed 's,^#!,,'`" || PYTHON_PY3QT5="" | ||
[ -s "$0"-py2gtk2 -a -x "$0"-py2gtk2 ] && PYTHON_PY2GTK2_SHEBANG="`head -1 "$0"-py2gtk2 | sed 's,^#!,,'`" || PYTHON_PY2GTK2_SHEBANG="" | ||
[ -s "$0"-py3qt5 -a -x "$0"-py3qt5 ] && PYTHON_PY3QT5_SHEBANG="`head -1 "$0"-py3qt5 | sed 's,^#!,,'`" || PYTHON_PY3QT5_SHEBANG="" | ||
SCRIPTDIR="`dirname "$0"`" && SCRIPTDIR="`cd "$SCRIPTDIR" && pwd`" || SCRIPTDIR="./" | ||
|
||
if [ -n "$PYTHON_PY2GTK2" ] \ | ||
&& (command -v $PYTHON_PY2GTK2) >/dev/null 2>/dev/null \ | ||
&& $PYTHON_PY2GTK2 -c "import re,glob,codecs,gtk,gtk.glade,gobject,ConfigParser" >/dev/null 2>/dev/null \ | ||
; then | ||
echo "PYTHON_PY2GTK2 is usable as: $PYTHON_PY2GTK2" >&2 | ||
else | ||
PYTHON_PY2GTK2="" | ||
fi | ||
PYTHON_PY2GTK2="" | ||
for P in "$PYTHON2" "$PYTHON_PY2GTK2_SHEBANG" "python2" "python" ; do | ||
if [ -n "$P" ] \ | ||
&& (command -v $P) >/dev/null 2>/dev/null \ | ||
&& $P -c "import re,glob,codecs,gtk,gtk.glade,gobject,ConfigParser" >/dev/null 2>/dev/null \ | ||
; then | ||
PYTHON_PY2GTK2="$P" | ||
echo "PYTHON_PY2GTK2 is usable as: $PYTHON_PY2GTK2" >&2 | ||
break | ||
fi | ||
done | ||
|
||
if [ -n "$PYTHON_PY3QT5" ] \ | ||
&& (command -v $PYTHON_PY3QT5) >/dev/null 2>/dev/null \ | ||
&& $PYTHON_PY3QT5 -c "import re,glob,codecs,PyQt5.uic,configparser" >/dev/null 2>/dev/null \ | ||
; then | ||
echo "PYTHON_PY3QT5 is usable as: $PYTHON_PY3QT5" >&2 | ||
else | ||
PYTHON_PY3QT5="" | ||
fi | ||
PYTHON_PY3QT5="" | ||
for P in "$PYTHON3" "$PYTHON_PY3QT5_SHEBANG" "python3" "python" ; do | ||
if [ -n "$P" ] \ | ||
&& (command -v $P) >/dev/null 2>/dev/null \ | ||
&& $P -c "import re,glob,codecs,PyQt5.uic,configparser" >/dev/null 2>/dev/null \ | ||
; then | ||
PYTHON_PY3QT5="$P" | ||
echo "PYTHON_PY3QT5 is usable as: $PYTHON_PY3QT5" >&2 | ||
break | ||
fi | ||
done | ||
|
||
for P in "$PYTHON_PY2GTK2" "$PYTHON_PY3QT5" ; do | ||
[ -n "$P" ] || continue | ||
|
@@ -50,16 +56,16 @@ done | |
|
||
if [ -n "$PYTHON_PY2GTK2" ] && [ -n "$PYTHON_PY3QT5" ] ; then | ||
if $PREFER_PY2 ; then | ||
exec "$0"-py2gtk2 "$@" | ||
exec $PYTHON_PY2GTK2 "$0"-py2gtk2 "$@" | ||
else | ||
exec "$0"-py3qt5 "$@" | ||
exec $PYTHON_PY3QT5 "$0"-py3qt5 "$@" | ||
fi | ||
else | ||
if [ -n "$PYTHON_PY2GTK2" ] ; then | ||
exec "$0"-py2gtk2 "$@" | ||
exec $PYTHON_PY2GTK2 "$0"-py2gtk2 "$@" | ||
fi | ||
if [ -n "$PYTHON_PY3QT5" ] ; then | ||
exec "$0"-py3qt5 "$@" | ||
exec $PYTHON_PY3QT5 "$0"-py3qt5 "$@" | ||
fi | ||
fi | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters