Skip to content

Commit 77dc6af

Browse files
committed
Remove unused sys_msgbox_for_installing function and its references
Signed-off-by: Samuel Amen Ague <ague.samuel27@gmail.com>
1 parent b555e9a commit 77dc6af

2 files changed

Lines changed: 13 additions & 103 deletions

File tree

pycompiler_ark/Plugins_SDK/GeneralContext/Dialog.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
ProgressDialog,
3030
_redact_secrets,
3131
show_msgbox,
32-
sys_msgbox_for_installing,
32+
3333
)
3434

3535
from .i18n import translate
@@ -169,15 +169,6 @@ def log_error(self, message: str) -> None:
169169
"""Log an error message."""
170170
self.console.print(f"❌ [bold red][ERROR][/bold red] {message}")
171171

172-
def sys_msgbox_for_installing(
173-
self,
174-
subject: str,
175-
explanation: Optional[str] = None,
176-
title: str = "Installation requise",
177-
) -> Optional[InstallAuth]:
178-
"""Show a system installation authorization dialog using Core.dialogs."""
179-
return sys_msgbox_for_installing(subject, explanation=explanation, title=title)
180-
181172
def progress(
182173
self, title: str, text: str = "", maximum: int = 0, cancelable: bool = False
183174
) -> ProgressDialog:

pycompiler_ark/Ui/Gui/WidgetsCreator.py

Lines changed: 12 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
"\nSur Windows, une élévation UAC sera demandée."
328-
if is_windows
329-
else "\nSur 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-
"\nOn Windows, a UAC elevation will be requested."
338-
if is_windows
339-
else "\nOn 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-
389308
class ProgressDialog(QDialog):
390309
"""Progress dialog tightly integrated with application."""
391310

0 commit comments

Comments
 (0)