Imported Upstream version 2.7.3

This commit is contained in:
Arnaud Quette 2015-04-30 15:53:36 +02:00
parent a356b56d11
commit fd413a3168
283 changed files with 14978 additions and 6511 deletions

View file

@ -3,6 +3,7 @@
EXTRA_DIST = README \
app/gui-1.3.glade \
app/NUT-Monitor \
app/nut-monitor.appdata.xml \
app/nut-monitor.desktop \
app/nut-monitor.png \
app/README \

View file

@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -17,23 +16,51 @@
# Network UPS Tools: data/html
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
test $$am__dry = yes; \
}
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -54,7 +81,7 @@ build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = scripts/python
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@ -83,6 +110,18 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
@ -90,10 +129,12 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
ASPELL = @ASPELL@
@ -200,12 +241,15 @@ SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOURCE_HIGHLIGHT = @SOURCE_HIGHLIGHT@
STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
TREE_VERSION = @TREE_VERSION@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
XMLLINT = @XMLLINT@
XSLTPROC = @XSLTPROC@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@ -250,6 +294,7 @@ localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
now = @now@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
@ -274,6 +319,7 @@ udevdir = @udevdir@
EXTRA_DIST = README \
app/gui-1.3.glade \
app/NUT-Monitor \
app/nut-monitor.appdata.xml \
app/nut-monitor.desktop \
app/nut-monitor.png \
app/README \
@ -326,11 +372,11 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
tags: TAGS
TAGS:
tags TAGS:
ctags: CTAGS
CTAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(DISTFILES)
@ -466,15 +512,16 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
cscopelist-am ctags-am distclean distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags-am uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.

View file

@ -23,12 +23,16 @@
#
# 2010-10-06 David Goncalves - Version 1.3
# Added localisation support
#
# 2015-02-14 Michal Fincham - Version 1.3.1
# Corrected unsafe permissions on ~/.nut-monitor (Debian #777706)
import gtk, gtk.glade, gobject
import sys
import base64
import os, os.path
import stat
import platform
import time
import threading
@ -44,21 +48,23 @@ gobject.threads_init()
class interface :
__widgets = {}
__callbacks = {}
__favorites = {}
__favorites_file = None
__favorites_path = ""
__fav_menu_items = list()
__window_visible = True
__glade_file = None
__connected = False
__ups_handler = None
__ups_commands = None
__ups_vars = None
__ups_rw_vars = None
__gui_thread = None
__current_ups = None
DESIRED_FAVORITES_DIRECTORY_MODE = 0700
__widgets = {}
__callbacks = {}
__favorites = {}
__favorites_file = None
__favorites_path = ""
__fav_menu_items = list()
__window_visible = True
__glade_file = None
__connected = False
__ups_handler = None
__ups_commands = None
__ups_vars = None
__ups_rw_vars = None
__gui_thread = None
__current_ups = None
def __init__( self ) :
@ -528,6 +534,9 @@ class interface :
return
try :
if ( not stat.S_IMODE( os.stat( self.__favorites_path ).st_mode ) == self.DESIRED_FAVORITES_DIRECTORY_MODE ) : # unsafe pre-1.2 directory found
os.chmod( self.__favorites_path, self.DESIRED_FAVORITES_DIRECTORY_MODE )
conf = ConfigParser.ConfigParser()
conf.read( self.__favorites_file )
for current in conf.sections() :
@ -573,7 +582,7 @@ class interface :
# If path does not exists, try to create it
if ( not os.path.exists( self.__favorites_file ) ) :
try :
os.makedirs( self.__favorites_path, mode=0700 )
os.makedirs( self.__favorites_path, mode=self.DESIRED_FAVORITES_DIRECTORY_MODE )
except :
self.gui_status_message( _("Error while creating configuration folder (%s)") % sys.exc_info()[1] )

View file

@ -1021,7 +1021,7 @@ want to delete from list...
<property name="window_position">center-always</property>
<property name="type_hint">normal</property>
<property name="program_name">NUT-Monitor</property>
<property name="version">1.3</property>
<property name="version">1.3.1</property>
<property name="copyright" translatable="yes">Copyright (c) 2010 David Goncalves</property>
<property name="comments" translatable="yes">GUI to manage devices connected a NUT server.

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2014 Arnaud Quette <arnaud.quette@free.fr> -->
<application>
<id type="desktop">nut-monitor.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0+</project_license>
<name>NUT Monitor</name>
<summary>GUI application to monitor UPS status</summary>
<description>
<p>
NUT Monitor is a GUI application to monitor UPS status, through NUT -
Network UPS Tools.
NUT is a client/server monitoring system that allows computers to
share uninterruptible power supply (UPS) and power distribution unit
(PDU) hardware. Clients access the hardware through the server, and
are notified whenever the power status changes.
</p>
<p>NUT Monitor provides the following features:</p>
<ul>
<li>Automatically connects to local UPS if there is only one managed</li>
<li>Command line options to start hidden, load a favorite, ...</li>
<li>System tray (notification area) integration, including notifications</li>
<li>Favorites, to store different devices</li>
<li>Display all device variables</li>
<li>Modify writable variables on UPS and devices</li>
<li>Support English and French</li>
</ul>
<p>
NUT Monitor requires that you have a running NUT system, that you can
connect to, either locally or remotely.
For more information on NUT: http://www.networkupstools.org/
</p>
</description>
<screenshots>
<screenshot type="default" width="620" height="349">http://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-1.png</screenshot>
<screenshot width="620" height="349">http://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-2.png</screenshot>
<screenshot width="620" height="349">http://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-3.png</screenshot>
</screenshots>
<url type="homepage">http://www.lestat.st/en/informatique/projets/nut-monitor</url>
<updatecontact>david@lestat.st</updatecontact>
<!-- project_group>GNOME</project_group -->
</application>

View file

@ -35,9 +35,16 @@
# 2012-02-07 René Martín Rodríguez <rmrodri@ull.es> - Version 1.2.2
# Added support for LIST CLIENTS command
#
# 2014-06-03 george2 - Version 1.3.0
# Added custom exception class, fixed minor bug, added Python 3 support.
#
import telnetlib
class PyNUTError( Exception ) :
""" Base class for custom exceptions """
class PyNUTClient :
""" Abstraction class to access NUT (Network UPS Tools) server """
@ -49,8 +56,8 @@ class PyNUTClient :
__timeout = None
__srv_handler = None
__version = "1.2.2"
__release = "2012-02-07"
__version = "1.3.0"
__release = "2014-06-03"
def __init__( self, host="127.0.0.1", port=3493, login=None, password=None, debug=False, timeout=5 ) :
@ -101,13 +108,13 @@ if something goes wrong.
self.__srv_handler.write( "USERNAME %s\n" % self.__login )
result = self.__srv_handler.read_until( "\n", self.__timeout )
if result[:2] != "OK" :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
if self.__password != None :
self.__srv_handler.write( "PASSWORD %s\n" % self.__password )
result = self.__srv_handler.read_until( "\n", self.__timeout )
if result[:2] != "OK" :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
def GetUPSList( self ) :
""" Returns the list of available UPS from the NUT server
@ -120,7 +127,7 @@ The result is a dictionary containing 'key->val' pairs of 'UPSName' and 'UPS Des
self.__srv_handler.write( "LIST UPS\n" )
result = self.__srv_handler.read_until( "\n" )
if result != "BEGIN LIST UPS\n" :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
result = self.__srv_handler.read_until( "END LIST UPS\n" )
ups_list = {}
@ -144,7 +151,7 @@ available vars.
self.__srv_handler.write( "LIST VAR %s\n" % ups )
result = self.__srv_handler.read_until( "\n" )
if result != "BEGIN LIST VAR %s\n" % ups :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
ups_vars = {}
result = self.__srv_handler.read_until( "END LIST VAR %s\n" % ups )
@ -170,7 +177,7 @@ of the command as value
self.__srv_handler.write( "LIST CMD %s\n" % ups )
result = self.__srv_handler.read_until( "\n" )
if result != "BEGIN LIST CMD %s\n" % ups :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
ups_cmds = {}
result = self.__srv_handler.read_until( "END LIST CMD %s\n" % ups )
@ -185,7 +192,7 @@ of the command as value
self.__srv_handler.write( "GET CMDDESC %s %s\n" % ( ups, var ) )
temp = self.__srv_handler.read_until( "\n" )
if temp[:7] != "CMDDESC" :
raise
raise PyNUTError
else :
off = len( "CMDDESC %s %s " % ( ups, var ) )
desc = temp[off:-1].split('"')[1]
@ -207,7 +214,7 @@ The result is presented as a dictionary containing 'key->val' pairs
self.__srv_handler.write( "LIST RW %s\n" % ups )
result = self.__srv_handler.read_until( "\n" )
if ( result != "BEGIN LIST RW %s\n" % ups ) :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
result = self.__srv_handler.read_until( "END LIST RW %s\n" % ups )
offset = len( "VAR %s" % ups )
@ -237,7 +244,7 @@ rights to set it (maybe login/password).
if ( result == "OK\n" ) :
return( "OK" )
else :
raise Exception, result
raise PyNUTError( result )
def RunUPSCommand( self, ups="", command="" ) :
""" Send a command to the specified UPS
@ -253,7 +260,7 @@ Returns OK on success or raises an error
if ( result == "OK\n" ) :
return( "OK" )
else :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
def FSD( self, ups="") :
""" Send FSD command
@ -267,7 +274,7 @@ Returns OK on success or raises an error
self.__srv_handler.write( "MASTER %s\n" % ups )
result = self.__srv_handler.read_until( "\n" )
if ( result != "OK MASTER-GRANTED\n" ) :
raise Exception, ( "Master level function are not available", "" )
raise PyNUTError( ( "Master level function are not available", "" ) )
if self.__debug :
print( "[DEBUG] FSD called..." )
@ -276,7 +283,7 @@ Returns OK on success or raises an error
if ( result == "OK FSD-SET\n" ) :
return( "OK" )
else :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
def help(self) :
""" Send HELP command
@ -307,7 +314,7 @@ The result is a dictionary containing 'key->val' pairs of 'UPSName' and a list o
print( "[DEBUG] ListClients from server" )
if ups and (ups not in self.GetUPSList()):
raise Exception, "%s is not a valid UPS" % ups
raise PyNUTError( "%s is not a valid UPS" % ups )
if ups:
self.__srv_handler.write( "LIST CLIENTS %s\n" % ups)
@ -315,7 +322,7 @@ The result is a dictionary containing 'key->val' pairs of 'UPSName' and a list o
self.__srv_handler.write( "LIST CLIENTS\n" )
result = self.__srv_handler.read_until( "\n" )
if result != "BEGIN LIST CLIENTS\n" :
raise Exception, result.replace( "\n", "" )
raise PyNUTError( result.replace( "\n", "" ) )
result = self.__srv_handler.read_until( "END LIST CLIENTS\n" )
ups_list = {}