File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ def list_clients(self, ups=None):
221221 The result is a dictionary containing 'key->val' pairs of
222222 'UPSName' and a list of clients.
223223 """
224- logging .debug ("list_clients from server" )
224+ logging .debug ("list_clients from '%s'..." , ups or " server" )
225225
226226 if ups and (ups not in self .list_ups ()):
227227 raise PyNUTError ("%s is not a valid UPS" % ups )
@@ -235,17 +235,16 @@ def list_clients(self, ups=None):
235235 raise PyNUTError (result .replace ("\n " , "" ))
236236
237237 result = self ._srv_handler .read_until ("END LIST CLIENTS\n " )
238- ups_dict = {}
239238
239+ clients = {}
240240 for line in result .split ("\n " ):
241- if line [:6 ] == "CLIENT" :
242- host , ups = line [7 :].split (' ' )
243- ups .replace (' ' , '' )
244- if not ups in ups_dict :
245- ups_dict [ups ] = []
246- ups_dict [ups ].append (host )
241+ if line .startswith ("CLIENT" ):
242+ host , ups = line [len ("CLIENT " ):].split (' ' )[:2 ]
243+ if not ups in clients :
244+ clients [ups ] = []
245+ clients [ups ].append (host )
247246
248- return ups_dict
247+ return clients
249248
250249 def list_rw_vars (self , ups = "" ):
251250 """Get a list of all writable vars from the selected UPS.
You can’t perform that action at this time.
0 commit comments