Damien Elmes 2018-10-28 11:41:43 +10:00
parent b4f4e65c55
commit a4edc57dc5
2 changed files with 11 additions and 10 deletions

View file

@ -18,6 +18,7 @@ from hashlib import sha1
import platform import platform
import traceback import traceback
import json import json
from contextlib import contextmanager
from anki.lang import _, ngettext from anki.lang import _, ngettext
@ -314,6 +315,13 @@ def namedtmp(name, rm=True):
# Cmd invocation # Cmd invocation
############################################################################## ##############################################################################
@contextmanager
def noBundledLibs():
oldlpath = os.environ.pop("LD_LIBRARY_PATH", None)
yield
if oldlpath is not None:
os.environ["LD_LIBRARY_PATH"] = oldlpath
def call(argv, wait=True, **kwargs): def call(argv, wait=True, **kwargs):
"Execute a command. If WAIT, return exit code." "Execute a command. If WAIT, return exit code."
# ensure we don't open a separate window for forking process on windows # ensure we don't open a separate window for forking process on windows
@ -327,7 +335,8 @@ def call(argv, wait=True, **kwargs):
si = None si = None
# run # run
try: try:
o = subprocess.Popen(argv, startupinfo=si, **kwargs) with noBundledLibs():
o = subprocess.Popen(argv, startupinfo=si, **kwargs)
except OSError: except OSError:
# command not found # command not found
return -1 return -1

View file

@ -6,15 +6,7 @@ from aqt.qt import *
import re, os, sys, urllib.request, urllib.parse, urllib.error, subprocess import re, os, sys, urllib.request, urllib.parse, urllib.error, subprocess
import aqt import aqt
from anki.sound import stripSounds from anki.sound import stripSounds
from anki.utils import isWin, isMac, invalidFilename from anki.utils import isWin, isMac, invalidFilename, noBundledLibs
from contextlib import contextmanager
@contextmanager
def noBundledLibs():
oldlpath = os.environ.pop("LD_LIBRARY_PATH", None)
yield
if oldlpath is not None:
os.environ["LD_LIBRARY_PATH"] = oldlpath
def openHelp(section): def openHelp(section):
link = aqt.appHelpSite link = aqt.appHelpSite