@@ -102,13 +102,13 @@ def __connect( self ) :
102
102
self ._srv_handler .write ( "USERNAME %s\n " % self .__login )
103
103
result = self ._srv_handler .read_until ( "\n " , self .__timeout )
104
104
if result [:2 ] != "OK" :
105
- raise Exception , result .replace ( "\n " , "" )
105
+ raise Exception ( result .replace ( "\n " , "" ) )
106
106
107
107
if self .__password != None :
108
108
self ._srv_handler .write ( "PASSWORD %s\n " % self .__password )
109
109
result = self ._srv_handler .read_until ( "\n " , self .__timeout )
110
110
if result [:2 ] != "OK" :
111
- raise Exception , result .replace ( "\n " , "" )
111
+ raise Exception ( result .replace ( "\n " , "" ) )
112
112
113
113
def GetUPSList ( self ) :
114
114
""" Returns the list of available UPS from the NUT server
@@ -121,7 +121,7 @@ def GetUPSList( self ) :
121
121
self ._srv_handler .write ( "LIST UPS\n " )
122
122
result = self ._srv_handler .read_until ( "\n " )
123
123
if result != "BEGIN LIST UPS\n " :
124
- raise Exception , result .replace ( "\n " , "" )
124
+ raise Exception ( result .replace ( "\n " , "" ) )
125
125
126
126
result = self ._srv_handler .read_until ( "END LIST UPS\n " )
127
127
ups_list = {}
@@ -145,7 +145,7 @@ def GetUPSVars( self, ups="" ) :
145
145
self ._srv_handler .write ( "LIST VAR %s\n " % ups )
146
146
result = self ._srv_handler .read_until ( "\n " )
147
147
if result != "BEGIN LIST VAR %s\n " % ups :
148
- raise Exception , result .replace ( "\n " , "" )
148
+ raise Exception ( result .replace ( "\n " , "" ) )
149
149
150
150
ups_vars = {}
151
151
result = self ._srv_handler .read_until ( "END LIST VAR %s\n " % ups )
@@ -171,7 +171,7 @@ def GetUPSCommands( self, ups="" ) :
171
171
self ._srv_handler .write ( "LIST CMD %s\n " % ups )
172
172
result = self ._srv_handler .read_until ( "\n " )
173
173
if result != "BEGIN LIST CMD %s\n " % ups :
174
- raise Exception , result .replace ( "\n " , "" )
174
+ raise Exception ( result .replace ( "\n " , "" ) )
175
175
176
176
ups_cmds = {}
177
177
result = self ._srv_handler .read_until ( "END LIST CMD %s\n " % ups )
@@ -208,7 +208,7 @@ def GetRWVars( self, ups="" ) :
208
208
self ._srv_handler .write ( "LIST RW %s\n " % ups )
209
209
result = self ._srv_handler .read_until ( "\n " )
210
210
if ( result != "BEGIN LIST RW %s\n " % ups ) :
211
- raise Exception , result .replace ( "\n " , "" )
211
+ raise Exception ( result .replace ( "\n " , "" ) )
212
212
213
213
result = self ._srv_handler .read_until ( "END LIST RW %s\n " % ups )
214
214
offset = len ( "VAR %s" % ups )
@@ -238,7 +238,7 @@ def SetRWVar( self, ups="", var="", value="" ):
238
238
if ( result == "OK\n " ) :
239
239
return ( "OK" )
240
240
else :
241
- raise Exception , result
241
+ raise Exception ( result )
242
242
243
243
def RunUPSCommand ( self , ups = "" , command = "" ) :
244
244
""" Send a command to the specified UPS
@@ -254,7 +254,7 @@ def RunUPSCommand( self, ups="", command="" ) :
254
254
if ( result == "OK\n " ) :
255
255
return ( "OK" )
256
256
else :
257
- raise Exception , result .replace ( "\n " , "" )
257
+ raise Exception ( result .replace ( "\n " , "" ) )
258
258
259
259
def FSD ( self , ups = "" ) :
260
260
""" Send FSD command
@@ -268,7 +268,7 @@ def FSD( self, ups="") :
268
268
self ._srv_handler .write ( "MASTER %s\n " % ups )
269
269
result = self ._srv_handler .read_until ( "\n " )
270
270
if ( result != "OK MASTER-GRANTED\n " ) :
271
- raise Exception , ( "Master level function are not available" , "" )
271
+ raise Exception (( "Master level function are not available" , "" ) )
272
272
273
273
if self .__debug :
274
274
print ( "[DEBUG] FSD called..." )
@@ -277,7 +277,7 @@ def FSD( self, ups="") :
277
277
if ( result == "OK FSD-SET\n " ) :
278
278
return ( "OK" )
279
279
else :
280
- raise Exception , result .replace ( "\n " , "" )
280
+ raise Exception ( result .replace ( "\n " , "" ) )
281
281
282
282
def help (self ) :
283
283
""" Send HELP command
@@ -308,15 +308,15 @@ def ListClients( self, ups = None ) :
308
308
print ( "[DEBUG] ListClients from server" )
309
309
310
310
if ups and (ups not in self .GetUPSList ()):
311
- raise Exception , "%s is not a valid UPS" % ups
311
+ raise Exception ( "%s is not a valid UPS" % ups )
312
312
313
313
if ups :
314
314
self ._srv_handler .write ( "LIST CLIENTS %s\n " % ups )
315
315
else :
316
316
self ._srv_handler .write ( "LIST CLIENTS\n " )
317
317
result = self ._srv_handler .read_until ( "\n " )
318
318
if result != "BEGIN LIST CLIENTS\n " :
319
- raise Exception , result .replace ( "\n " , "" )
319
+ raise Exception ( result .replace ( "\n " , "" ) )
320
320
321
321
result = self ._srv_handler .read_until ( "END LIST CLIENTS\n " )
322
322
ups_list = {}
0 commit comments