mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux: Workaround for systems with broken xdg-open implementations that do not unquote urls before passing them to applications
This commit is contained in:
parent
2af36a378b
commit
7bae9efc65
@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
""" The GUI """
|
""" The GUI """
|
||||||
import os, sys, Queue, threading, glob
|
import os, sys, Queue, threading, glob
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from threading import RLock, Lock
|
from threading import RLock, Lock, Thread
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from PyQt5.QtWidgets import QStyle # Gives a nicer error message than import from Qt
|
from PyQt5.QtWidgets import QStyle # Gives a nicer error message than import from Qt
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
@ -1140,6 +1140,15 @@ def open_local_file(path):
|
|||||||
if iswindows:
|
if iswindows:
|
||||||
with sanitize_env_vars():
|
with sanitize_env_vars():
|
||||||
os.startfile(os.path.normpath(path))
|
os.startfile(os.path.normpath(path))
|
||||||
|
elif islinux or isbsd:
|
||||||
|
import subprocess
|
||||||
|
if isinstance(path, unicode):
|
||||||
|
path = path.encode(filesystem_encoding)
|
||||||
|
with sanitize_env_vars():
|
||||||
|
p = subprocess.Popen(['xdg-open', path])
|
||||||
|
t = Thread(name='WaitXDGOpen', target=p.wait)
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
else:
|
else:
|
||||||
url = QUrl.fromLocalFile(path)
|
url = QUrl.fromLocalFile(path)
|
||||||
open_url(url)
|
open_url(url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user