@@ -232,20 +232,20 @@ def _show_in_main_thread():
232232 mb .setDefaultButton (ok )
233233 _ = mb .exec_ () if hasattr (mb , "exec_" ) else mb .exec ()
234234 return None
235- except Exception :
235+ except Exception :
236+ try :
237+ from pycompiler_ark .Ui import output
238+
239+ lvl = "warning" if kind in ("warning" , "error" ) else "info"
236240 try :
237- from pycompiler_ark .Ui import output
238-
239- lvl = "warning" if kind in ("warning" , "error" ) else "info"
240- try :
241- output .log (lvl , f"[MSGBOX:{ kind } ] { title } : { text } " , gui = None )
242- except Exception :
243- if lvl in ("warning" , "error" ):
244- output .warn (f"[MSGBOX:{ kind } ] { title } : { text } " , gui = None )
245- else :
246- output .info (f"[MSGBOX:{ kind } ] { title } : { text } " , gui = None )
241+ output .log (lvl , f"[MSGBOX:{ kind } ] { title } : { text } " , gui = None )
247242 except Exception :
248- pass
243+ if lvl in ("warning" , "error" ):
244+ output .warn (f"[MSGBOX:{ kind } ] { title } : { text } " , gui = None )
245+ else :
246+ output .info (f"[MSGBOX:{ kind } ] { title } : { text } " , gui = None )
247+ except Exception :
248+ pass
249249 return _show_rich_msgbox (kind , title , text , default = default )
250250
251251 return _invoke_in_main_thread (_show_in_main_thread )
@@ -305,87 +305,6 @@ def _show_rich_msgbox(
305305 return None
306306
307307
308- def sys_msgbox_for_installing (
309- subject : str , explanation : Optional [str ] = None , title : str = "Installation requise"
310- ) -> Optional [InstallAuth ]:
311- """Interactive prompt for multi-OS installation authorization."""
312- is_windows = platform .system ().lower ().startswith ("win" )
313- try :
314- from pycompiler_ark .Ui .i18n import is_french_language , tr_fr_en
315-
316- if title == "Installation requise" :
317- title = tr_fr_en (None , "Installation requise" , "Installation required" )
318- is_fr = is_french_language (None )
319- except Exception :
320- is_fr = True
321-
322- if is_fr :
323- msg = (
324- f"L'installation de '{ subject } ' nécessite des privilèges administrateur.\n "
325- + (f"\n { explanation } \n " if explanation else "" )
326- + (
327- "\n Sur Windows, une élévation UAC sera demandée."
328- if is_windows
329- else "\n Sur Linux/macOS, votre mot de passe sudo est requis."
330- )
331- )
332- else :
333- msg = (
334- f"Installing '{ subject } ' requires administrator privileges.\n "
335- + (f"\n { explanation } \n " if explanation else "" )
336- + (
337- "\n On Windows, a UAC elevation will be requested."
338- if is_windows
339- else "\n On Linux/macOS, your sudo password is required."
340- )
341- )
342- if QApplication .instance () is not None and not _use_rich_dialogs ():
343- try :
344- parent = _qt_active_parent ()
345- proceed = show_msgbox ("question" , title , msg , default = "Yes" )
346- if not proceed :
347- return None
348- if is_windows :
349- return InstallAuth ("uac" , None )
350- pwd , ok = QInputDialog .getText (
351- parent ,
352- title ,
353- (
354- "Entrez votre mot de passe (sudo):"
355- if is_fr
356- else "Enter your password (sudo):"
357- ),
358- QLineEdit .Password ,
359- )
360- if not ok :
361- return None
362- pwd = str (pwd )
363- return InstallAuth ("sudo" , pwd ) if pwd else None
364- except Exception :
365- pass
366- try :
367- try :
368- from pycompiler_ark .Ui import output
369-
370- output .log ("info" , f"[INSTALL] { title } : { msg } " , gui = None )
371- except Exception :
372- pass
373- ans = (
374- input ("Continuer ? [y/N] " if is_fr else "Continue? [y/N] " ).strip ().lower ()
375- )
376- if ans not in ("y" , "yes" , "o" , "oui" ):
377- return None
378- except Exception :
379- pass
380- if is_windows :
381- return InstallAuth ("uac" , None )
382- try :
383- pwd = getpass .getpass ("Mot de passe (sudo): " if is_fr else "Password (sudo): " )
384- return InstallAuth ("sudo" , pwd ) if pwd else None
385- except Exception :
386- return None
387-
388-
389308class ProgressDialog (QDialog ):
390309 """Progress dialog tightly integrated with application."""
391310
0 commit comments