@@ -316,16 +316,15 @@ def getNumberOfAxes(self):
316316 else :
317317 self ._numAxes = self ._getNumberOfMacroStationAxes ()
318318 if self .verboseMode :
319- log .info ("Total number of axes is %d." % self ._numAxes )
319+ log .info (f "Total number of axes is { self ._numAxes } ." )
320320 return self ._numAxes
321321
322322 def checkAxisIsInRange (self , axis ):
323323 if axis < 0 :
324324 raise ValueError ("Asking for a negative axis" )
325325 if axis > self .getNumberOfAxes ():
326326 raise ValueError (
327- "Requested axis %d but PMAC has only %d axes"
328- % (axis , self .getNumberOfAxes ())
327+ f"Requested axis { axis } but PMAC has only { self .getNumberOfAxes ()} axes"
329328 )
330329
331330 # Returns: Macro station number
@@ -337,7 +336,7 @@ def getAxisMacroStationNumber(self, axis, macroAxisStartIndex=0):
337336 return self .MACRO_STATION_LOOKUP_TABLE [axis - 1 ]
338337 else :
339338 if axis <= 8 :
340- raise ValueError ("Axis %d is not on the MACRO ring" % axis )
339+ raise ValueError (f "Axis { axis } is not on the MACRO ring" )
341340 else :
342341 return (
343342 self .MACRO_STATION_LOOKUP_TABLE [(axis - 8 ) - 1 ]
@@ -359,7 +358,7 @@ def getIVars(self, base, offsets):
359358 iVars = (base + x for x in offsets )
360359 cmd = ""
361360 for iVar in iVars :
362- cmd += "i%d " % iVar
361+ cmd += f"i { iVar } "
363362 (retStr , status ) = self .sendCommand (cmd )
364363 if status :
365364 return retStr .split ("\r " )[:- 1 ]
@@ -385,15 +384,15 @@ def getAxisSetupIVars(self, axis, offsets):
385384 def setAxisSetupIVar (self , axis , offset , value ):
386385 self .checkAxisIsInRange (axis )
387386 iVar = 100 * axis + offset
388- self .setVar ("i%d" % iVar , value )
387+ self .setVar (f"i { iVar } " , value )
389388
390389 # Get macro station I-variables for a particular axis (or None on failure)
391390 def getAxisMsIVars (self , axis , msIVars , macroAxisStart = 0 ):
392391 self .checkAxisIsInRange (axis )
393392 macroStationNo = self .getAxisMacroStationNumber (axis , macroAxisStart )
394393 cmd = ""
395394 for msIVar in msIVars :
396- cmd += "ms%d,i%d " % ( macroStationNo , msIVar )
395+ cmd += f "ms{ macroStationNo } ,i { msIVar } "
397396 (retStr , status ) = self .sendCommand (cmd )
398397 if status :
399398 return retStr .split ("\r " )[:- 1 ]
@@ -403,7 +402,7 @@ def getAxisMsIVars(self, axis, msIVars, macroAxisStart=0):
403402 def setAxisMsIVar (self , axis , iVar , value ):
404403 self .checkAxisIsInRange (axis )
405404 macroStationNo = self .getAxisMacroStationNumber (axis )
406- self .setVar ("ms%d,i%d" % ( macroStationNo , iVar ) , value )
405+ self .setVar (f "ms{ macroStationNo } ,i { iVar } " , value )
407406
408407 # Calculate the base I-variable number in the I70mn (say, "I7000+") range
409408 # for an onboard Geobrick axis.
@@ -413,7 +412,7 @@ def getOnboardAxisI7000PlusVarsBase(self, axis):
413412 # If not a Geobrick axis, raise an exception
414413 self .checkAxisIsInRange (axis )
415414 if self .isMacroStationAxis (axis ):
416- raise ValueError ("Axis %d is not an onboard axis" % axis )
415+ raise ValueError (f "Axis { axis } is not an onboard axis" )
417416
418417 # Calculate the base
419418 m = (axis - 1 ) // 4 # m in 0..9
@@ -428,7 +427,7 @@ def getOnboardAxisI7000PlusVars(self, axis, offsets):
428427 def setOnboardAxisI7000PlusIVar (self , axis , offset , value ):
429428 base = self .getOnboardAxisI7000PlusVarsBase (axis )
430429 iVar = base + offset
431- self .setVar ("i%d" % iVar , value )
430+ self .setVar (f"i { iVar } " , value )
432431
433432 # function that sends out a whole list of commands to the pmac
434433 # (like from a file...). The function waits for a response from each command
@@ -565,8 +564,8 @@ def testGetAxisMacroStationNumber(self):
565564 for i in range (1 , 33 ):
566565 try :
567566 log .info (
568- "pmac.getAxisMacroStationNumber(%d ) returns %s."
569- % ( i , repr (self .getAxisMacroStationNumber (i )))
567+ f "pmac.getAxisMacroStationNumber({ i } ) returns \
568+ { repr (self .getAxisMacroStationNumber (i ))} ."
570569 )
571570 except Exception :
572571 log .debug ("pmac.getAxisMacroStationNumber(%d)" , i , exc_info = True )
@@ -575,8 +574,8 @@ def testIsMacroStationAxis(self):
575574 for i in range (1 , 33 ):
576575 try :
577576 log .info (
578- "pmac.isMacroStationAxis(%d ) returns %s."
579- % ( i , repr (self .isMacroStationAxis (i )))
577+ f "pmac.isMacroStationAxis({ i } ) returns \
578+ { repr (self .isMacroStationAxis (i ))} ."
580579 )
581580 except Exception :
582581 log .debug ("pmac.isMacroStationAxis(%d)" , i , exc_info = True )
@@ -704,7 +703,7 @@ def getNumberOfAxes(self):
704703 (retStr , wasSuccessful ) = self .sendCommand ("Sys.MaxMotors" )
705704 numMotors = int (retStr ) - 1
706705 if self .verboseMode :
707- log .info ("Total number of motors is %d." % numMotors )
706+ log .info (f "Total number of motors is { numMotors } ." )
708707 return numMotors
709708
710709 def _sendCommand (self , command , shouldWait = True , doubleTimeout = False ):
@@ -834,9 +833,7 @@ def connect(self, updatesReadyEvent=None):
834833 )
835834 self .sock .connect ((self .hostname , self .port ))
836835 if self .verboseMode :
837- log .warning (
838- 'Connected to host "%s" on port %d' % (self .hostname , self .port )
839- )
836+ log .warning (f'Connected to host "{ self .hostname } " on port { self .port } ' )
840837 except socket .gaierror :
841838 return "ERROR: unknown host"
842839 except Exception :
0 commit comments