Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ https://github.com/networkupstools/nut/milestone/13
- Second-level bullet points listed in this file will now use 4 spaces
(not 3 like before) for easier initial indentation of new entries.

- The PyQt5 and PyQt6 NUT-Monitor commands now share one Python 3
implementation. The dispatcher accepts `NUT_MONITOR_QT=5` or
`NUT_MONITOR_QT=6` to require a particular backend. [PR #3596]

- Introduced an experimental `apcmicrolink` driver for devices with
the APC Microlink protocol on serial port connections. Tested against
APC Smart-UPS 750 (SMT750RMI2UC). [PR #3406]
Expand Down
7 changes: 5 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7478,6 +7478,11 @@ AC_CONFIG_FILES([
Makefile
])

AC_CONFIG_FILES([scripts/python/app/NUT-Monitor-py3qt5:scripts/python/app/NUT-Monitor-py3qt.in],
[chmod +x scripts/python/app/NUT-Monitor-py3qt5])
AC_CONFIG_FILES([scripts/python/app/NUT-Monitor-py3qt6:scripts/python/app/NUT-Monitor-py3qt.in],
[chmod +x scripts/python/app/NUT-Monitor-py3qt6])

AC_MSG_NOTICE([Generating templated script files that should be marked executable])
m4_foreach_w([SCRIPTFILE], [
docs/docinfo.xml.sh
Expand All @@ -7489,8 +7494,6 @@ m4_foreach_w([SCRIPTFILE], [
scripts/augeas/gen-nutupsconf-aug.py
scripts/external_apis/enphase/enphase-monitor
scripts/python/app/NUT-Monitor-py2gtk2
scripts/python/app/NUT-Monitor-py3qt5
scripts/python/app/NUT-Monitor-py3qt6
scripts/python/module/test_nutclient.py
scripts/upsdrvsvcctl/nut-driver-enumerator.sh
scripts/upsdrvsvcctl/upsdrvsvcctl
Expand Down
7 changes: 4 additions & 3 deletions docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,10 @@ of Python does not matter and the un-versioned `PYTHON` value is substituted
into files as the script shebang, used to find the `site-packages` location,
etc.

One exception is generation of NUT-Monitor GUI application, being separated
for `NUT-Monitor-py2gtk2`, `NUT-Monitor-py3qt5`, `NUT-Monitor-py3qt6` due
to further backend platform technical differences -- these build products
One exception is generation of NUT-Monitor GUI application. It provides a
Python 2/GTK2 implementation and one shared Python 3 implementation for the
Qt5 and Qt6 backends, exposed as `NUT-Monitor-py2gtk2`,
`NUT-Monitor-py3qt5` and `NUT-Monitor-py3qt6`. These build products
specifically use `PYTHON2` and `PYTHON3` substitutions. They may also be
co-installed on the same system. A dispatcher shell script `NUT-Monitor` is
used to launch the preferred (newest) or the only existing implementation.
Expand Down
16 changes: 11 additions & 5 deletions docs/man/NUT-Monitor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SYNOPSIS

*NUT-Monitor-py3qt6*

[PREFER_PY2=true] [PYTHON2=python2.7] [PYTHON3=python3.14w] *NUT-Monitor*
[PREFER_PY2=true] [NUT_MONITOR_QT=auto|5|6] [PYTHON2=python2.7] [PYTHON3=python3.14w] *NUT-Monitor*

DESCRIPTION
-----------
Expand All @@ -30,11 +30,11 @@ as part of NUT; also releases of the module are published as a PyPI package.
* `NUT-Monitor-py2gtk2` is an implementation that relies on a Python 2.x
interpreter (tested with 2.6 or 2.7 generation) and GTK2 UI library;

* `NUT-Monitor-py3qt5` is an implementation that relies on a Python 3.x
interpreter and QT5 UI library;
* `NUT-Monitor-py3qt5` runs the shared Python 3.x implementation with the
QT5 UI library;

* `NUT-Monitor-py3qt6` is an implementation that relies on a Python 3.x
interpreter and QT6 UI library;
* `NUT-Monitor-py3qt6` runs the shared Python 3.x implementation with the
QT6 UI library;

* `NUT-Monitor` is a shell script to pick at run-time the best implementation.
In older NUT releases, this was the file name used by the Python 2.x variant
Expand Down Expand Up @@ -82,6 +82,12 @@ The `PREFER_PY2=true` or `PREFER_PY2=false` environment variable value
can be used to select the implementation of the client to use if both
ecosystems are usable on the current system.

The `NUT_MONITOR_QT=5` or `NUT_MONITOR_QT=6` environment variable requires
that Python 3 backend when using the `NUT-Monitor` dispatcher. The default
value `auto` prefers Qt6 and falls back to Qt5. The explicit
`NUT-Monitor-py3qt5` and `NUT-Monitor-py3qt6` commands always select their
named backend.

Note that the implementation for Python 2.x / GTK2 is slightly better
regarding localization; functionally they should be equivalent.

Expand Down
16 changes: 7 additions & 9 deletions scripts/python/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,15 @@ NUT_MONITOR_PY3_COMMON = \
NUT_MONITOR_PY3QT5 = \
app/nut-monitor-py3qt5.desktop

NUT_MONITOR_PY3QT5_TEMPLATE = \
app/NUT-Monitor-py3qt5.in
NUT_MONITOR_PY3QT_TEMPLATE = \
app/NUT-Monitor-py3qt.in

NUT_MONITOR_PY3QT5_GENERATED_SCRIPT = \
app/NUT-Monitor-py3qt5
Comment thread
jimklimov marked this conversation as resolved.

NUT_MONITOR_PY3QT6 = \
app/nut-monitor-py3qt6.desktop

NUT_MONITOR_PY3QT6_TEMPLATE = \
app/NUT-Monitor-py3qt6.in

NUT_MONITOR_PY3QT6_GENERATED_SCRIPT = \
app/NUT-Monitor-py3qt6

Expand Down Expand Up @@ -153,17 +150,18 @@ NUT_MONITOR_DISPATCHER_NOEXEC = \
NUT_MONITOR_DISPATCHER_SCRIPT = \
app/NUT-Monitor

TESTS = app/NUT-Monitor-test.sh

#################################################################
# `make dist` tarball contents:
EXTRA_DIST = \
$(NUT_MONITOR_DISPATCHER_NOEXEC) $(NUT_MONITOR_DISPATCHER_SCRIPT) \
$(NUT_MONITOR_COMMON) $(NUT_MONITOR_COMMON_TEMPLATE) \
$(PYNUT_COMMON) $(PYNUT_TEMPLATE)
$(PYNUT_COMMON) $(PYNUT_TEMPLATE) $(TESTS)

EXTRA_DIST += $(NUT_MONITOR_PY2GTK2) $(NUT_MONITOR_PY2GTK2_TEMPLATE)
EXTRA_DIST += $(NUT_MONITOR_PY3_COMMON) \
$(NUT_MONITOR_PY3QT5) $(NUT_MONITOR_PY3QT5_TEMPLATE) \
$(NUT_MONITOR_PY3QT6) $(NUT_MONITOR_PY3QT6_TEMPLATE)
EXTRA_DIST += $(NUT_MONITOR_PY3_COMMON) $(NUT_MONITOR_PY3QT_TEMPLATE) \
$(NUT_MONITOR_PY3QT5) $(NUT_MONITOR_PY3QT6)

#################################################################
# `make install` handling (nobase_ to keep tree structure):
Expand Down
6 changes: 3 additions & 3 deletions scripts/python/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ This directory contains the `NUT-Monitor` UI application, which uses the
NOTE: Do not mistake it for `nut-monitor` service for the `upsmon` client in
some distributions' NUT packaging.

There are three closely related separate implementations, for Python 2 with GTK2
and for Python 3 with Qt5 and Qt6. Either can be installed at the same time, if
your distribution has not yet outlawed the obsolete Python 2 interpreters.
There is a Python 2/GTK2 implementation and a shared Python 3 implementation
for the Qt5 and Qt6 backends. They can be installed at the same time, if your
distribution has not yet outlawed the obsolete Python 2 interpreters.

To install it, you will either need to keep the files together, or to install:

Expand Down
55 changes: 33 additions & 22 deletions scripts/python/app/NUT-Monitor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ case "${PREFER_PY2-}" in
;;
esac

case "${NUT_MONITOR_QT-auto}" in
""|auto) NUT_MONITOR_QT=auto ;;
5|6) ;;
*) echo "Unsupported value of NUT_MONITOR_QT='$NUT_MONITOR_QT'; expected 'auto', '5' or '6'" >&2
exit 2
;;
esac

# Detect which variant of NUT-Monitor we can run on the local system:
[ -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=""
Expand Down Expand Up @@ -75,28 +83,31 @@ for P in "$PYTHON_PY2GTK2" "$PYTHON_PY3QT5" "$PYTHON_PY3QT6" ; do
fi
done

if [ -n "$PYTHON_PY2GTK2" ] && [ -n "$PYTHON_PY3QT5" ] && [ -n "$PYTHON_PY3QT6" ] ; then
if $PREFER_PY2 ; then
echo "Starting $0-py2gtk2 variant..." >&2
exec $PYTHON_PY2GTK2 "$0"-py2gtk2 "$@"
else
echo "Starting $0-py3qt6 variant..." >&2
exec $PYTHON_PY3QT6 "$0"-py3qt6 "$@"
fi
else
if [ -n "$PYTHON_PY2GTK2" ] ; then
echo "Starting $0-py2gtk2 variant..." >&2
exec $PYTHON_PY2GTK2 "$0"-py2gtk2 "$@"
fi
if [ -n "$PYTHON_PY3QT6" ] ; then
echo "Starting $0-py3qt6 variant..." >&2
exec $PYTHON_PY3QT6 "$0"-py3qt6 "$@"
fi
if [ -n "$PYTHON_PY3QT5" ] ; then
echo "Starting $0-py3qt5 variant..." >&2
exec $PYTHON_PY3QT5 "$0"-py3qt5 "$@"
fi
case "$NUT_MONITOR_QT" in
5) PYTHON_PY2GTK2=""; PYTHON_PY3QT6="" ;;
6) PYTHON_PY2GTK2=""; PYTHON_PY3QT5="" ;;
esac

if [ -n "$PYTHON_PY2GTK2" ] && $PREFER_PY2 ; then
echo "Starting $0-py2gtk2 variant..." >&2
exec $PYTHON_PY2GTK2 "$0"-py2gtk2 "$@"
fi
if [ -n "$PYTHON_PY3QT6" ] ; then
echo "Starting $0-py3qt6 variant..." >&2
exec $PYTHON_PY3QT6 "$0"-py3qt6 "$@"
fi
if [ -n "$PYTHON_PY3QT5" ] ; then
echo "Starting $0-py3qt5 variant..." >&2
exec $PYTHON_PY3QT5 "$0"-py3qt5 "$@"
fi
if [ -n "$PYTHON_PY2GTK2" ] ; then
echo "Starting $0-py2gtk2 variant..." >&2
exec $PYTHON_PY2GTK2 "$0"-py2gtk2 "$@"
fi

echo "ERROR: No usable Python interpreter version (with needed modules) was found" >&2
if [ "$NUT_MONITOR_QT" = auto ] ; then
echo "ERROR: No usable Python interpreter version (with needed modules) was found" >&2
else
echo "ERROR: Requested PyQt$NUT_MONITOR_QT implementation is not usable" >&2
fi
exit 1
Loading
Loading