@@ -280,32 +280,20 @@ def set_var(self, ups="", var="", value=""):
280280
281281 self ._srv_handler .write ("SET VAR %s %s %s\n " % (ups , var , value ))
282282 result = self ._srv_handler .read_until ("\n " )
283- if result == "OK\n " :
284- return True
285- else :
286- raise PyNUTError (result )
283+ if result != "OK\n " :
284+ raise PyNUTError (result .replace ("\n " , "" ))
287285
288286 def run_command (self , ups = "" , command = "" ):
289- """Send a command to the specified UPS.
290-
291- Returns OK on success or raises an error.
292- """
293-
287+ """Send a command to the specified UPS."""
294288 logging .debug ("run_command called..." )
295289
296290 self ._srv_handler .write ("INSTCMD %s %s\n " % (ups , command ))
297291 result = self ._srv_handler .read_until ("\n " )
298- if result == "OK\n " :
299- return True
300- else :
292+ if result != "OK\n " :
301293 raise PyNUTError (result .replace ("\n " , "" ))
302294
303295 def fsd (self , ups = "" ):
304- """Send FSD command.
305-
306- Returns OK on success or raises an error.
307- """
308-
296+ """Send FSD command."""
309297 logging .debug ("MASTER called..." )
310298
311299 self ._srv_handler .write ("MASTER %s\n " % ups )
@@ -316,22 +304,18 @@ def fsd(self, ups=""):
316304 logging .debug ("FSD called..." )
317305 self ._srv_handler .write ("FSD %s\n " % ups )
318306 result = self ._srv_handler .read_until ("\n " )
319- if result == "OK FSD-SET\n " :
320- return True
321- else :
307+ if result != "OK FSD-SET\n " :
322308 raise PyNUTError (result .replace ("\n " , "" ))
323309
324310 def help (self ):
325311 """Send HELP command."""
326-
327312 logging .debug ("HELP called..." )
328313
329314 self ._srv_handler .write ("HELP\n " )
330315 return self ._srv_handler .read_until ("\n " )
331316
332317 def ver (self ):
333318 """Send VER command."""
334-
335319 logging .debug ("VER called..." )
336320
337321 self ._srv_handler .write ("VER\n " )
0 commit comments