GUIClient doesn't open url under Linux
Closed this issue · 0 comments
Inky19 commented
When calling GUIClient(path=gui_path)
, the error Could not open URL
is raised and nothing opens.
This is due to the implementation of the open_file()
method in gui_client.py
:
@staticmethod
def open_file(url):
try:
os.startfile(url)
except AttributeError:
try:
subprocess.call(["open", url])
except Exception:
logger.debug("Could not open URL")
os.startfile(url)
fails because it is only available on Windows (source)- the
subprocess
also fails becauseopen
is a command reserved for MacOS, and is not valid under Linux.
A simple solution would be to use xdg-open
when Linux is detected, which seems to be the equivalent (source). This worked for me at least.
A library to help with os.startfile
on different OS seems to exist (universal-startfile), but I know nothing about its reliability.
Environment used:
- OS: Manjaro Linux (kernel 6.6)
- Python: 3.11.6