Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37041131
en ru br
Репозитории ALT
S:2.8.0-alt2
5.1: 2.0.5-alt4
4.1: 2.0.5-alt3
4.0: 2.0.5-alt2
3.0: 2.0.2-alt1
www.altlinux.org/Changes

Группа :: Система/Серверы
Пакет: nut

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: nut-2.8.0-unreachable.patch
Скачать


diff -up nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable nut-2.6.5/scripts/python/app/NUT-Monitor-py2gtk2.in
--- 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-py2gtk2.in	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/app/NUT-Monitor.unreachable nut-2.6.5/scripts/python/app/NUT-Monitor-py3qt5.in
--- 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-py3qt5.in	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.in
--- 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.in	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
 
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin