mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-11 01:24:36 +00:00
try fix webbrowser again
This commit is contained in:
parent
fec3246ca9
commit
e07de2ea92
2 changed files with 11 additions and 11 deletions
20
koboldcpp.py
20
koboldcpp.py
|
@ -1845,18 +1845,18 @@ ws ::= | " " | "\n" [ \t]{0,20}
|
|||
|
||||
def LaunchWebbrowser(target_url, failedmsg):
|
||||
try:
|
||||
import webbrowser as wb
|
||||
if wb.open(target_url, autoraise=True):
|
||||
return # If successful, exit the function
|
||||
raise RuntimeError("wb.open failed, using fallback")
|
||||
if os.name == "posix" and "DISPLAY" in os.environ: # UNIX-like systems
|
||||
import subprocess
|
||||
result = subprocess.run(["xdg-open", target_url], check=True)
|
||||
if result.returncode == 0:
|
||||
return # fallback successful
|
||||
raise RuntimeError("no xdg-open")
|
||||
except Exception:
|
||||
try:
|
||||
if os.name == "posix" and "DISPLAY" in os.environ: # UNIX-like systems
|
||||
import subprocess
|
||||
result = subprocess.run(["xdg-open", target_url], check=True)
|
||||
if result.returncode == 0:
|
||||
return # fallback successful
|
||||
raise RuntimeError("fallback failed")
|
||||
import webbrowser as wb
|
||||
if wb.open(target_url, autoraise=True):
|
||||
return # If successful, exit the function
|
||||
raise RuntimeError("wb.open failed")
|
||||
except Exception:
|
||||
print(failedmsg)
|
||||
print(f"Please manually open your browser to {target_url}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue