forked from openlp/openlp
Revert some changes from the HEAD merge; Add the lib directory to sys.path for running tests
This commit is contained in:
parent
dad969bc0e
commit
f74e0c7dc8
@ -78,7 +78,7 @@ class Path(PathVariant):
|
|||||||
:param onerror: Handler function to handle any errors
|
:param onerror: Handler function to handle any errors
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
shutil.rmtree(str(self), ignore_errors, onerror)
|
shutil.rmtree(self, ignore_errors, onerror)
|
||||||
|
|
||||||
|
|
||||||
def replace_params(args, kwargs, params):
|
def replace_params(args, kwargs, params):
|
||||||
|
@ -28,7 +28,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from distutils.version import LooseVersion
|
import vlc
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
|
|
||||||
@ -65,59 +65,19 @@ def get_vlc():
|
|||||||
|
|
||||||
:return: The "vlc" module, or None
|
:return: The "vlc" module, or None
|
||||||
"""
|
"""
|
||||||
if 'openlp.core.ui.media.vendor.vlc' in sys.modules:
|
if 'vlc' in sys.modules:
|
||||||
# If VLC has already been imported, no need to do all the stuff below again
|
# If VLC has already been imported, no need to do all the stuff below again
|
||||||
is_vlc_available = False
|
is_vlc_available = False
|
||||||
try:
|
try:
|
||||||
is_vlc_available = bool(sys.modules['openlp.core.ui.media.vendor.vlc'].get_default_instance())
|
is_vlc_available = bool(sys.modules['vlc'].get_default_instance())
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if is_vlc_available:
|
if is_vlc_available:
|
||||||
return sys.modules['openlp.core.ui.media.vendor.vlc']
|
return sys.modules['vlc']
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
is_vlc_available = False
|
|
||||||
try:
|
|
||||||
if is_macosx():
|
|
||||||
# Newer versions of VLC on OS X need this. See https://forum.videolan.org/viewtopic.php?t=124521
|
|
||||||
os.environ['VLC_PLUGIN_PATH'] = '/Applications/VLC.app/Contents/MacOS/plugins'
|
|
||||||
# On Windows when frozen in PyInstaller, we need to blank SetDllDirectoryW to allow loading of the VLC dll.
|
|
||||||
# This is due to limitations (by design) in PyInstaller. SetDllDirectoryW original value is restored once
|
|
||||||
# VLC has been imported.
|
|
||||||
if is_win():
|
|
||||||
buffer_size = 1024
|
|
||||||
dll_directory = ctypes.create_unicode_buffer(buffer_size)
|
|
||||||
new_buffer_size = ctypes.windll.kernel32.GetDllDirectoryW(buffer_size, dll_directory)
|
|
||||||
dll_directory = ''.join(dll_directory[:new_buffer_size]).replace('\0', '')
|
|
||||||
log.debug('Original DllDirectory: %s' % dll_directory)
|
|
||||||
ctypes.windll.kernel32.SetDllDirectoryW(None)
|
|
||||||
from openlp.core.ui.media.vendor import vlc
|
|
||||||
if is_win():
|
|
||||||
ctypes.windll.kernel32.SetDllDirectoryW(dll_directory)
|
|
||||||
is_vlc_available = bool(vlc.get_default_instance())
|
|
||||||
except (ImportError, NameError, NotImplementedError):
|
|
||||||
pass
|
|
||||||
except OSError as e:
|
|
||||||
# this will get raised the first time
|
|
||||||
if is_win():
|
|
||||||
if not isinstance(e, WindowsError) and e.winerror != 126:
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
if is_vlc_available:
|
|
||||||
try:
|
|
||||||
VERSION = vlc.libvlc_get_version().decode('UTF-8')
|
|
||||||
except Exception:
|
|
||||||
VERSION = '0.0.0'
|
|
||||||
# LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower).
|
|
||||||
# http://bugs.python.org/issue14894
|
|
||||||
if LooseVersion(VERSION.split()[0]) < LooseVersion('1.1.0'):
|
|
||||||
is_vlc_available = False
|
|
||||||
log.debug('VLC could not be loaded, because the vlc version is too old: %s' % VERSION)
|
|
||||||
if is_vlc_available:
|
|
||||||
return vlc
|
|
||||||
else:
|
else:
|
||||||
return None
|
return vlc
|
||||||
|
|
||||||
|
|
||||||
# On linux we need to initialise X threads, but not when running tests.
|
# On linux we need to initialise X threads, but not when running tests.
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
"""
|
"""
|
||||||
This module runs a Pyro4 server using LibreOffice's version of Python
|
This module runs a Pyro4 server using LibreOffice's version of Python
|
||||||
|
|
||||||
|
Please Note: This intentionally uses os.path over pathlib because we don't know which version of Python is shipped with
|
||||||
|
the version of LibreOffice on the user's computer.
|
||||||
"""
|
"""
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
import sys
|
import sys
|
||||||
@ -36,6 +39,8 @@ if sys.platform.startswith('darwin'):
|
|||||||
logging.basicConfig(filename=logfile, level=logging.INFO)
|
logging.basicConfig(filename=logfile, level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
# Add the current directory to sys.path so that we can load the serializers
|
||||||
|
sys.path.append(os.path.join(os.path.dirname(__file__)))
|
||||||
# Add the vendor directory to sys.path so that we can load Pyro4
|
# Add the vendor directory to sys.path so that we can load Pyro4
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'vendor'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), 'vendor'))
|
||||||
|
|
||||||
|
@ -42,8 +42,12 @@ def set_up_fault_handling():
|
|||||||
"""
|
"""
|
||||||
Set up the Python fault handler
|
Set up the Python fault handler
|
||||||
"""
|
"""
|
||||||
create_paths(AppLocation.get_directory(AppLocation.CacheDir))
|
# Create the cache directory if it doesn't exist, and enable the fault handler to log to an error log file
|
||||||
faulthandler.enable((AppLocation.get_directory(AppLocation.CacheDir) / 'error.log').open('wb'))
|
try:
|
||||||
|
create_paths(AppLocation.get_directory(AppLocation.CacheDir))
|
||||||
|
faulthandler.enable((AppLocation.get_directory(AppLocation.CacheDir) / 'error.log').open('wb'))
|
||||||
|
except OSError:
|
||||||
|
log.exception('An exception occurred when enabling the fault handler')
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
|
@ -89,7 +89,8 @@ MODULES = [
|
|||||||
'webob',
|
'webob',
|
||||||
'requests',
|
'requests',
|
||||||
'qtawesome',
|
'qtawesome',
|
||||||
'pymediainfo'
|
'pymediainfo',
|
||||||
|
'vlc'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -158,6 +159,8 @@ def check_module(mod, text='', indent=' '):
|
|||||||
w('OK')
|
w('OK')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
w('FAIL')
|
w('FAIL')
|
||||||
|
except Exception:
|
||||||
|
w('ERROR')
|
||||||
w(os.linesep)
|
w(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user