]>
Commit | Line | Data |
---|---|---|
e25b7168 AM |
1 | diff -up nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable nut-2.6.5/scripts/python/app/NUT-Monitor |
2 | --- nut-2.6.5/scripts/python/app/NUT-Monitor.unreachable 2012-07-31 19:38:56.000000000 +0200 | |
3 | +++ nut-2.6.5/scripts/python/app/NUT-Monitor 2013-01-07 18:04:26.532531441 +0100 | |
4 | @@ -674,6 +674,11 @@ class interface : | |
5 | self.gui_status_notification( _("Device '%s' not found on server") % self.__current_ups, "warning.png" ) | |
6 | return | |
7 | ||
8 | + if not self.__ups_handler.CheckUPSAvailable( self.__current_ups ): | |
9 | + self.gui_status_message( _("UPS '{0}' is not reachable").format( self.__current_ups ) ) | |
10 | + self.gui_status_notification( _("UPS '{0}' is not reachable").format( self.__current_ups ), "warning.png" ) | |
11 | + return | |
12 | + | |
13 | self.__connected = True | |
14 | self.__widgets["ups_connect"].hide() | |
15 | self.__widgets["ups_disconnect"].show() | |
16 | diff -up nut-2.6.5/scripts/python/module/PyNUT.py.unreachable nut-2.6.5/scripts/python/module/PyNUT.py | |
17 | --- nut-2.6.5/scripts/python/module/PyNUT.py.unreachable 2012-07-31 19:38:56.000000000 +0200 | |
18 | +++ nut-2.6.5/scripts/python/module/PyNUT.py 2013-01-07 17:41:26.548440712 +0100 | |
19 | @@ -158,6 +158,20 @@ available vars. | |
20 | ||
21 | return( ups_vars ) | |
22 | ||
23 | + def CheckUPSAvailable( self, ups="") : | |
24 | + """ Check whether UPS is reachable | |
25 | + | |
26 | +Just tries to contact UPS with safe command. | |
27 | +The result is True (rechable) or False (unreachable) | |
28 | + """ | |
29 | + self.__srv_handler.write( "LIST CMD %s\n" % ups ) | |
30 | + result = self.__srv_handler.read_until( "\n" ) | |
31 | + if result != "BEGIN LIST CMD %s\n" % ups : | |
32 | + return False | |
33 | + | |
34 | + self.__srv_handler.read_until( "END LIST CMD %s\n" % ups ) | |
35 | + return True | |
36 | + | |
37 | def GetUPSCommands( self, ups="" ) : | |
38 | """ Get all available commands for the specified UPS | |
39 |