[nut/f18] do not traceback when ups is not reachable
Michal Hlavinka
mhlavink at fedoraproject.org
Mon Jan 7 17:41:10 UTC 2013
commit 61862cb985a0e90061610a0f2f89260665b50c6c
Author: Michal Hlavinka <mhlavink at redhat.com>
Date: Mon Jan 7 18:41:04 2013 +0100
do not traceback when ups is not reachable
nut-2.6.5-unreachable.patch | 39 +++++++++++++++++++++++++++++++++++++++
nut.spec | 7 ++++++-
2 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/nut-2.6.5-unreachable.patch b/nut-2.6.5-unreachable.patch
new file mode 100644
index 0000000..3c9db41
--- /dev/null
+++ b/nut-2.6.5-unreachable.patch
@@ -0,0 +1,39 @@
+diff -up nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable nut-2.6.5/scripts/python/app/NUT-Monitor
+--- nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable 2012-07-31 19:38:56.000000000 +0200
++++ nut-2.6.5/scripts/python/app/NUT-Monitor 2013-01-07 18:04:26.532531441 +0100
+@@ -674,6 +674,11 @@ class interface :
+ self.gui_status_notification( _("Device '%s' not found on server") % self.__current_ups, "warning.png" )
+ return
+
++ if not self.__ups_handler.CheckUPSAvailable( self.__current_ups ):
++ self.gui_status_message( _("UPS '{0}' is not reachable").format( self.__current_ups ) )
++ self.gui_status_notification( _("UPS '{0}' is not reachable").format( self.__current_ups ), "warning.png" )
++ return
++
+ self.__connected = True
+ self.__widgets["ups_connect"].hide()
+ self.__widgets["ups_disconnect"].show()
+diff -up nut-2.6.5/scripts/python/module/PyNUT.py.unreachable nut-2.6.5/scripts/python/module/PyNUT.py
+--- nut-2.6.5/scripts/python/module/PyNUT.py.unreachable 2012-07-31 19:38:56.000000000 +0200
++++ nut-2.6.5/scripts/python/module/PyNUT.py 2013-01-07 17:41:26.548440712 +0100
+@@ -158,6 +158,20 @@ available vars.
+
+ return( ups_vars )
+
++ def CheckUPSAvailable( self, ups="") :
++ """ Check whether UPS is reachable
++
++Just tries to contact UPS with safe command.
++The result is True (rechable) or False (unreachable)
++ """
++ self.__srv_handler.write( "LIST CMD %s\n" % ups )
++ result = self.__srv_handler.read_until( "\n" )
++ if result != "BEGIN LIST CMD %s\n" % ups :
++ return False
++
++ self.__srv_handler.read_until( "END LIST CMD %s\n" % ups )
++ return True
++
+ def GetUPSCommands( self, ups="" ) :
+ """ Get all available commands for the specified UPS
+
diff --git a/nut.spec b/nut.spec
index 3acd183..4142a6c 100644
--- a/nut.spec
+++ b/nut.spec
@@ -13,7 +13,7 @@
Summary: Network UPS Tools
Name: nut
Version: 2.6.5
-Release: 6%{?dist}
+Release: 7%{?dist}
Group: Applications/System
License: GPLv2+ and GPLv3+
Url: http://www.networkupstools.org/
@@ -28,6 +28,7 @@ Patch4: nut-2.6.5-ipmifix.patch
Patch5: nut-2.6.5-dlfix.patch
Patch6: nut-2.6.5-pthreadfix.patch
Patch7: nut-2.6.5-foreground.patch
+Patch8: nut-2.6.5-unreachable.patch
Requires(pre): shadow-utils udev
Requires(post): fileutils chkconfig systemd-units
@@ -122,6 +123,7 @@ necessary to develop NUT client applications.
%patch5 -p1 -b .dlfix
%patch6 -p1 -b .pthreadfix
%patch7 -p1 -b .foreground
+%patch8 -p1 -b .unreachable
sed -i 's|=NUT-Monitor|=nut-monitor|' scripts/python/app/nut-monitor.desktop
sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor
sed -i 's|LIBSSL_LDFLAGS|LIBSSL_LIBS|' lib/libupsclient-config.in
@@ -406,6 +408,9 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/libnutscan.pc
%changelog
+* Mon Jan 07 2013 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-7
+- do not traceback when ups is not reachable
+
* Fri Sep 14 2012 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-6
- use new systemd macros (#857416)
More information about the scm-commits
mailing list