@@ -125,7 +125,7 @@ def __init__(self, options, run_prologue=True, excepthook=None, **kwargs):
125125 """
126126
127127 options_ = _merge_options (options )
128- super (ExtendedSimpleOption , self ).__init__ (options_ , ** kwargs )
128+ super ().__init__ (options_ , ** kwargs )
129129
130130 self .nagios_reporter = None
131131 self .lockfile = None
@@ -223,11 +223,11 @@ def critical_exception_handler(self, tp, value, traceback):
223223 """
224224 self .log .exception ("unhandled exception detected: %s - %s" , tp , value )
225225 self .log .debug ("traceback %s" , traceback )
226- message = "Script failure: %s - %s" % ( tp , value )
226+ message = f "Script failure: { tp } - { value } "
227227 self .critical (message )
228228
229229
230- class CLI ( object ) :
230+ class CLI :
231231 """
232232 Base class to implement cli tools that require timestamps, nagios checks, etc.
233233 """
@@ -271,13 +271,13 @@ def make_options(self, defaults=None):
271271 # insert default timestamp value file based on name
272272 if TIMESTAMP_FILE_OPTION in options :
273273 tsopt = list (options [TIMESTAMP_FILE_OPTION ])
274- tsopt [- 1 ] = os .path .join (self .CACHE_DIR , "%s.timestamp" % self .name )
274+ tsopt [- 1 ] = os .path .join (self .CACHE_DIR , f" { self .name } .timestamp" )
275275 options [TIMESTAMP_FILE_OPTION ] = tuple (tsopt )
276276
277277 options .update (self .CLI_OPTIONS )
278278
279279 if TIMESTAMP_FILE_OPTION not in options and self .TIMESTAMP_MANDATORY :
280- raise Exception ( "no mandatory %s option defined" % ( TIMESTAMP_FILE_OPTION ,) )
280+ raise ValueError ( f "no mandatory { TIMESTAMP_FILE_OPTION } option defined" )
281281
282282 return ExtendedSimpleOption (options )
283283
@@ -332,7 +332,7 @@ def do(self, dry_run): #pylint: disable=unused-argument
332332 self.thresholds can be used to pass the thresholds during epilogue
333333 """
334334 logging .error ("`do` method not implemented" )
335- raise Exception ("Not implemented" )
335+ raise NotImplementedError ("Not implemented" )
336336 return "Not implemented"
337337
338338 def make_time (self ):
@@ -375,14 +375,13 @@ def post(self, errors, current_time=None):
375375 _ , timestamp = convert_timestamp (current_time )
376376 write_timestamp (self .options .timestamp_file , timestamp )
377377 except Exception as err :
378- txt = "Writing timestamp %s to %s failed: %s" % ( timestamp , self .options .timestamp_file , err )
378+ txt = f "Writing timestamp { timestamp } to { self .options .timestamp_file } failed: { err } "
379379 self .critical_exception (txt , err )
380380
381381 def final (self ):
382382 """
383383 Run as finally block in main
384384 """
385- pass
386385
387386 def main (self ):
388387 """
@@ -406,14 +405,14 @@ def main(self):
406405
407406 self .post (errors )
408407
409- self .fulloptions .epilogue ("%s complete" % msg , self .thresholds )
408+ self .fulloptions .epilogue (f" { msg } complete" , self .thresholds )
410409
411410
412411
413412class NrpeCLI (CLI ):
414413
415414 def __init__ (self , name = None , default_options = None ):
416- super (NrpeCLI , self ).__init__ (name = name , default_options = default_options )
415+ super ().__init__ (name = name , default_options = default_options )
417416
418417 def ok (self , msg ):
419418 """
0 commit comments