mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-08 18:30:50 +00:00
added more sanity checks on zenity
This commit is contained in:
parent
ffa0bc21e6
commit
6bc2ca4803
1 changed files with 14 additions and 0 deletions
14
koboldcpp.py
14
koboldcpp.py
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue