@@ -181,7 +181,7 @@ def required_tools(self) -> dict[str, list[str]]:
181181 """
182182 return {"python" : [], "system" : []}
183183
184- def ensure_tools_installed (self , gui ) -> bool :
184+ def ensure_tools_installed (self , gui , stop_signal : Optional [ Callable [[], bool ]] = None ) -> bool :
185185 """
186186 Check if all required tools are installed, and install missing ones.
187187 Uses direct SysDependencyManager integration for system packages with full GUI support.
@@ -234,37 +234,47 @@ def ensure_tools_installed(self, gui) -> bool:
234234 # Use Linux package installation with progress dialog
235235 process = sys_manager .install_packages_linux (missing_system )
236236 if process :
237- # Wait for completion with timeout
238- if process .waitForFinished (600000 ): # 10 minutes
239- if process .exitCode () == 0 :
240- log_i18n_level (
241- gui ,
242- "success" ,
243- * _tools_stage_message (
244- "system" ,
245- f"Outils système installés avec succès: { missing_system } " ,
246- f"System tools installed successfully: { missing_system } " ,
247- ),
248- )
249- else :
237+ # Wait for completion with timeout, but check stop_signal
238+ timeout_total = 600000 # 10 minutes
239+ elapsed = 0
240+ interval = 500 # 0.5s
241+ while not process .waitForFinished (interval ):
242+ if stop_signal and stop_signal ():
243+ process .terminate ()
244+ process .waitForFinished (1000 )
245+ process .kill ()
246+ return False
247+ elapsed += interval
248+ if elapsed >= timeout_total :
250249 log_i18n_level (
251250 gui ,
252- "error " ,
251+ "warning " ,
253252 * _tools_stage_message (
254253 "system" ,
255- f"Échec installation outils système: { missing_system } (code: { process . exitCode () } ) " ,
256- f"System tools installation failed: { missing_system } (code: { process . exitCode () } ) " ,
254+ "Timeout lors de l'installation des outils système " ,
255+ "Timeout during system tools installation " ,
257256 ),
258257 )
259- system_install_ok = False
258+ return False
259+
260+ if process .exitCode () == 0 :
261+ log_i18n_level (
262+ gui ,
263+ "success" ,
264+ * _tools_stage_message (
265+ "system" ,
266+ f"Outils système installés avec succès: { missing_system } " ,
267+ f"System tools installed successfully: { missing_system } " ,
268+ ),
269+ )
260270 else :
261271 log_i18n_level (
262272 gui ,
263- "warning " ,
273+ "error " ,
264274 * _tools_stage_message (
265275 "system" ,
266- "Timeout lors de l' installation des outils système" ,
267- "Timeout during system tools installation" ,
276+ f"Échec installation outils système: { missing_system } (code: { process . exitCode () } ) " ,
277+ f"System tools installation failed: { missing_system } (code: { process . exitCode () } ) " ,
268278 ),
269279 )
270280 system_install_ok = False
@@ -310,36 +320,46 @@ def ensure_tools_installed(self, gui) -> bool:
310320 winget_packages
311321 )
312322 if process :
313- if process .waitForFinished (600000 ): # 10 minutes
314- if process .exitCode () == 0 :
323+ timeout_total = 600000 # 10 minutes
324+ elapsed = 0
325+ interval = 500 # 0.5s
326+ while not process .waitForFinished (interval ):
327+ if stop_signal and stop_signal ():
328+ process .terminate ()
329+ process .waitForFinished (1000 )
330+ process .kill ()
331+ return False
332+ elapsed += interval
333+ if elapsed >= timeout_total :
315334 log_i18n_level (
316335 gui ,
317- "success " ,
336+ "warning " ,
318337 * _tools_stage_message (
319338 "system" ,
320- f"Outils Windows installés: { missing_system } " ,
321- f"Windows tools installed: { missing_system } " ,
339+ "Timeout lors de l'installation Windows " ,
340+ "Timeout during Windows installation " ,
322341 ),
323342 )
324- else :
325- log_i18n_level (
326- gui ,
327- "error" ,
328- * _tools_stage_message (
329- "system" ,
330- f"Échec installation Windows: { missing_system } " ,
331- f"Windows installation failed: { missing_system } " ,
332- ),
333- )
334- system_install_ok = False
343+ return False
344+
345+ if process .exitCode () == 0 :
346+ log_i18n_level (
347+ gui ,
348+ "success" ,
349+ * _tools_stage_message (
350+ "system" ,
351+ f"Outils Windows installés: { missing_system } " ,
352+ f"Windows tools installed: { missing_system } " ,
353+ ),
354+ )
335355 else :
336356 log_i18n_level (
337357 gui ,
338- "warning " ,
358+ "error " ,
339359 * _tools_stage_message (
340360 "system" ,
341- "Timeout lors de l' installation Windows" ,
342- "Timeout during Windows installation" ,
361+ f"Échec installation Windows: { missing_system } " ,
362+ f" Windows installation failed: { missing_system } " ,
343363 ),
344364 )
345365 system_install_ok = False
@@ -404,6 +424,9 @@ def ensure_tools_installed(self, gui) -> bool:
404424 )
405425 system_install_ok = False
406426
427+ if stop_signal and stop_signal ():
428+ return False
429+
407430 # Check Python tools after the system phase, even if the system phase failed.
408431 if hasattr (gui , "venv_manager" ) and gui .venv_manager and python_tools :
409432 use_system = bool (getattr (gui , "use_system_python" , False ))
@@ -444,7 +467,7 @@ def ensure_tools_installed(self, gui) -> bool:
444467 venv_path , missing_python
445468 )
446469
447- return system_install_ok
470+ return system_install_ok and not ( stop_signal and stop_signal ())
448471 except Exception as e :
449472 log_i18n_level (
450473 gui ,
0 commit comments