Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 3.21 KB

README.adoc

File metadata and controls

76 lines (56 loc) · 3.21 KB

Python NUT Client files

This directory contains various NUT Client related Python scripts, written by David Goncalves, and released under GPL v3.

module

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 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.

telnetlib

Historically, the PyNUTClient class relied on telnetlib module for socket communications with the NUT data server, which was provided as part of Python core installation with tested 2.6+ and 3.* versions. The module was, however, marked deprecated since Python 3.11 and not provided since 3.13. Due to this, as a quick stop-gap solution, NUT sources provide nut_telnetlib.py - a copy of the module from Python 3.10 installation, and no longer should require its presence in the Python deployment.

A better solution would be to find or create a new layer for the constrained use-case of NUT client interactions with a data server, which do not need the fully fledged Telnet-like capabilities.

app

This directory contains the NUT-Monitor UI application, which uses the PyNUT class, along with its own resources.

There are two closely related separate implementations, for Python 2 with GTK2 and for Python 3 with Qt5. Both 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-py2gtk2 and/or NUT-Monitor-py3qt5 to /usr/bin/, /usr/X11R6/bin/ or something like that (optionally making a simple NUT-Monitor symlink to the preferred implementation version or using the provided wrapper script),

  • ui/.glade (for NUT-Monitor-py2gtk2) or ui/.ui (for NUT-Monitor-py3qt5) files to /usr/share/nut-monitor/,

  • nut-monitor.png to something like /usr/share/pixmaps/,

  • finally, nut-monitor-py2gtk2.desktop and/or nut-monitor-py3qt5.desktop (optionally symlinked as nut-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 script for more technical details.