mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-11 17:44:38 +00:00
better fallback browser support
This commit is contained in:
parent
44720fb34c
commit
0a6ccda203
1 changed files with 9 additions and 8 deletions
17
koboldcpp.py
17
koboldcpp.py
|
@ -1845,15 +1845,16 @@ def LaunchWebbrowser(target_url, failedmsg):
|
||||||
try:
|
try:
|
||||||
import webbrowser as wb
|
import webbrowser as wb
|
||||||
if wb.open(target_url, autoraise=True):
|
if wb.open(target_url, autoraise=True):
|
||||||
return
|
return # If successful, exit the function
|
||||||
raise RuntimeError("Cannot open default browser")
|
raise RuntimeError("wb.open failed, using fallback")
|
||||||
except Exception as e:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
print(f"Browser failed to launch: {e}, attempting to use xdg-open...")
|
if os.name == "posix" and "DISPLAY" in os.environ: # UNIX-like systems
|
||||||
import webbrowser as wb
|
import subprocess
|
||||||
if wb.get('xdg-open').open(target_url, autoraise=True):
|
result = subprocess.run(["xdg-open", target_url], check=True)
|
||||||
return
|
if result.returncode == 0:
|
||||||
raise RuntimeError("Cannot open xdg-open browser")
|
return # fallback successful
|
||||||
|
raise RuntimeError("fallback failed")
|
||||||
except Exception:
|
except Exception:
|
||||||
print(failedmsg)
|
print(failedmsg)
|
||||||
print(f"Please manually open your browser to {target_url}")
|
print(f"Please manually open your browser to {target_url}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue