This directory contains various NUT Client related Python scripts, written by David Goncalves, and released under GPL v3.
This directory contains PyNUT.py, which is a Python abstraction class to
access NUT data server(s). You can use it in Python programs to access NUT’s
upsd data server in a simple way, without having to know the NUT protocol.
The same module should work for Python 2 and Python 3.
To import it into Python programs you have to use the following line (case sensitive):
import PyNUT
This module provides a (PyNUT.)PyNUTClient class that can be used to connect
and get data from an upsd data server.
To install the PyNUT module on Debian/Ubuntu, copy it to:
/usr/share/python-support/python-pynut/
For quick tests, just make sure its directory is exported in PYTHONPATH
environment variable.
This directory also contains test_nutclient.py, which is a PyNUT test program
and it also serves as a code example. For this to be fully functional, you will
need to adapt the login, password and upsname to fit your configuration.
A NUT data server should be running for the test program to verify connection
and protocol support.
For one practical example, you can research tests/NIT/nit.sh in NUT sources.
There is a separate tests/pynut-commands-test.py whose invocation for any
currently configured Python version(s) is managed by tests/Makefile.am.
These tests require the unittest Python module, which is usually available
by default (we have seen only one build agent without it, for just one of its
many Python versions installed).
This directory contains the NUT-Monitor UI application, which uses the
PyNUT class, along with its own resources.
|
Note
|
Do not mistake it for nut-monitor service for the upsmon client in
some distributions' NUT packaging.
|
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:
-
Depending on the Python version(s) your system has, put
NUT-Monitor-py2gtk2and/orNUT-Monitor-py3qt5and/orNUT-Monitor-py3qt6to/usr/bin/,/usr/X11R6/bin/or something like that (optionally making a simpleNUT-Monitorsymlink the preferred implementation version or using the provided wrapper script), -
ui/.glade(forNUT-Monitor-py2gtk2) orui/.ui(forNUT-Monitor-py3qt5orNUT-Monitor-py3qt6) files to/usr/share/nut-monitor/, -
nut-monitor.pngto something like/usr/share/pixmaps/, -
finally,
nut-monitor-py2gtk2.desktopand/ornut-monitor-py3qt5.desktopand/ornut-monitor-py3qt6.desktop(optionally symlinked asnut-monitor.desktop) to/usr/share/applications/
The PyNUT module can be kept nearby, or must be installed as a "site" or
"vendor" provided script into your Python modules location. See the wrapper
scripts of the app for more technical details.