mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-06 04:51:17 +02:00
added more sanity checks on zenity
This commit is contained in:
@@ -3513,6 +3513,20 @@ def zenity(filetypes=None, initialdir="", initialfile="", **kwargs) -> Tuple[int
|
||||
.replace("?", "\\?").replace("&", "&").replace("|", "|").replace("<", "<").replace(">", ">")\
|
||||
.replace("(", "\\(").replace(")", "\\)").replace("[", "\\[").replace("]", "\\]").replace("{", "\\{").replace("}", "\\}")
|
||||
|
||||
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)
|
||||
if result.returncode == 0 and "Usage" in result.stdout:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
if not zenity_sanity_check():
|
||||
raise Exception("Zenity not working correctly, falling back to TK GUI.")
|
||||
|
||||
# Build args based on keywords
|
||||
args = ['/usr/bin/env', zenity_bin, '--file-selection']
|
||||
for k, v in kwargs.items():
|
||||
|
||||
Reference in New Issue
Block a user