add debugging info to zenity check

This commit is contained in:
Concedo 2025-04-27 23:48:23 +08:00
parent f77574765e
commit 5fa9e02bc3
2 changed files with 4 additions and 2 deletions

View file

@ -3650,12 +3650,14 @@ def zenity(filetypes=None, initialdir="", initialfile="", **kwargs) -> Tuple[int
def zenity_sanity_check(): #make sure zenity is sane
nonlocal zenity_bin
try: # Run `zenity --help` and pipe to grep
result = subprocess.run(f"{zenity_bin} --help | grep Usage", shell=True, capture_output=True, text=True, encoding='utf-8', timeout=10)
result = subprocess.run(f"{zenity_bin} --help", shell=True, capture_output=True, text=True, encoding='utf-8', timeout=10)
if result.returncode == 0 and "Usage" in result.stdout:
return True
else:
print(f"Zenity/YAD sanity check failed - ReturnCode={result.returncode}")
return False
except FileNotFoundError:
print(f"Zenity/YAD sanity check failed - {zenity_bin} not found")
return False
if not zenity_sanity_check():