@@ -90,7 +90,9 @@ def _start_process(self):
9090 assert self ._log_path
9191
9292 self ._logger .info (
93- f"Running command: { ' ' .join (self .command )} in { self .working_dir or os .getcwd ()} "
93+ "Running command: %s in %s" ,
94+ " " .join (self .command ),
95+ self .working_dir or os .getcwd (),
9496 )
9597
9698 stdin = subprocess .DEVNULL
@@ -139,7 +141,7 @@ def _remove_directory(self, path: str) -> None:
139141 try :
140142 shutil .rmtree (path , ignore_errors = True )
141143 except (OSError , IOError ) as e :
142- self ._logger .warning (f "Warning: Failed to remove directory { path } : { e } " )
144+ self ._logger .warning ("Warning: Failed to remove directory %s: %s" , path , e )
143145
144146 def _check_ports (self , timeout ):
145147 time_taken = 0
@@ -150,15 +152,15 @@ def _check_ports(self, timeout):
150152 def _check_port (self , port , timeout = 30 , sleep = 0.1 ):
151153 """Check if a port is open on localhost."""
152154 start_time = time .time ()
153- self ._logger .info (f "Checking Port: { port } " )
155+ self ._logger .info ("Checking Port: %s" , port )
154156 while time .time () - start_time < timeout :
155157 with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
156158 if s .connect_ex (("localhost" , port )) == 0 :
157- self ._logger .info (f "SUCCESS: Check Port:{ port } " )
159+ self ._logger .info ("SUCCESS: Check Port: %s" , port )
158160 return time .time () - start_time
159161 time .sleep (sleep )
160- self ._logger .error (f "FAILED: Check Port: { port } " )
161- raise RuntimeError (f "FAILED: Check Port: { port } " )
162+ self ._logger .error ("FAILED: Check Port: %s" , port )
163+ raise RuntimeError ("FAILED: Check Port: %s" % port )
162164
163165 def _check_urls (self , timeout ):
164166 time_taken = 0
@@ -173,39 +175,41 @@ def _check_url(self, url, timeout=30, sleep=0.1):
173175 else :
174176 response_check = None
175177 start_time = time .time ()
176- self ._logger .info (f"Checking URL { url } " )
177- while time .time () - start_time < timeout :
178+ self ._logger .info ("Checking URL %s" , url )
179+ elapsed = 0
180+ while elapsed < timeout :
178181 try :
179- response = requests .get (url , timeout = timeout )
182+ response = requests .get (url , timeout = timeout - elapsed )
180183 if response .status_code == 200 :
181184 if response_check is None or response_check (response ):
182- self ._logger .info (f "SUCCESS: Check URL:{ url } " )
185+ self ._logger .info ("SUCCESS: Check URL: %s" , url )
183186 return time .time () - start_time
184187 except requests .RequestException as e :
185- self ._logger .warning ( f "URL check failed: { e } " )
188+ self ._logger .warn ( "URL check failed: %s" , e )
186189 time .sleep (sleep )
190+ elapsed = time .time () - start_time
187191
188- self ._logger .error (f "FAILED: Check URL: { url } " )
189- raise RuntimeError (f "FAILED: Check URL: { url } " )
192+ self ._logger .error ("FAILED: Check URL: %s" , url )
193+ raise RuntimeError ("FAILED: Check URL: %s" % url )
190194
191195 def _terminate_existing (self ):
192196 if self .terminate_existing :
193- self ._logger .info (f "Terminating Existing { self ._command_name } " )
197+ self ._logger .info ("Terminating Existing %s" , self ._command_name )
194198 for proc in psutil .process_iter (["name" , "cmdline" ]):
195199 if proc .name () == self ._command_name or proc .name () in self .stragglers :
196200 self ._terminate_process_tree (proc .pid )
197201
198202 def _terminate_process (self , process ):
199203 try :
200- self ._logger .info (f "Terminating { process } " )
204+ self ._logger .info ("Terminating %s" , process )
201205 process .terminate ()
202206 except psutil .AccessDenied :
203- self ._logger .warning (f "Access denied for PID { process .pid } " )
207+ self ._logger .warning ("Access denied for PID %s" , process .pid )
204208 except psutil .NoSuchProcess :
205- self ._logger .warning (f "PID { process . pid } no longer exists" )
209+ self ._logger .warning ("PID %s no longer exists" , process . pid )
206210 except psutil .TimeoutExpired :
207211 self ._logger .warning (
208- f "PID { process . pid } did not terminate before timeout, killing"
212+ "PID %s did not terminate before timeout, killing" , process . pid
209213 )
210214 process .kill ()
211215
0 commit comments