mirror of https://gitlab.com/openlp/openlp.git
Upgrade to Pyro5
This commit is contained in:
parent
8187b94855
commit
f59146b505
|
@ -19,7 +19,7 @@
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
##########################################################################
|
##########################################################################
|
||||||
"""
|
"""
|
||||||
This module runs a Pyro4 server using LibreOffice's version of Python
|
This module runs a Pyro5 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
|
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.
|
the version of LibreOffice on the user's computer.
|
||||||
|
@ -40,11 +40,11 @@ if sys.platform.startswith('darwin') and 'pytest' not in sys.argv[0]:
|
||||||
|
|
||||||
# Add the current directory to sys.path so that we can load the serializers
|
# Add the current directory to sys.path so that we can load the serializers
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__)))
|
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 Pyro5
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'vendor'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), 'vendor'))
|
||||||
|
|
||||||
from serializers import register_classes
|
from serializers import register_classes
|
||||||
from Pyro4 import Daemon, expose
|
from Pyro5.api import Daemon, expose
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Wrap these imports in a try so that we can run the tests on macOS
|
# Wrap these imports in a try so that we can run the tests on macOS
|
||||||
|
@ -81,7 +81,7 @@ class LibreOfficeException(Exception):
|
||||||
@expose
|
@expose
|
||||||
class LibreOfficeServer(object):
|
class LibreOfficeServer(object):
|
||||||
"""
|
"""
|
||||||
A Pyro4 server which controls LibreOffice
|
A Pyro5 server which controls LibreOffice
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -36,7 +36,7 @@ LIBREOFFICE_PATH = Path('/Applications/LibreOffice.app')
|
||||||
LIBREOFFICE_PYTHON = LIBREOFFICE_PATH / 'Contents' / 'Resources' / 'python'
|
LIBREOFFICE_PYTHON = LIBREOFFICE_PATH / 'Contents' / 'Resources' / 'python'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Pyro4 import Proxy
|
from Pyro5.client import Proxy
|
||||||
if is_macosx() and LIBREOFFICE_PATH.exists():
|
if is_macosx() and LIBREOFFICE_PATH.exists():
|
||||||
macuno_available = True
|
macuno_available = True
|
||||||
else:
|
else:
|
||||||
|
@ -46,7 +46,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
if macuno_available:
|
if macuno_available:
|
||||||
# If this controller is good to go, register the serializer classes with Pyro4
|
# If this controller is good to go, register the serializer classes with Pyro5
|
||||||
from openlp.plugins.presentations.lib.serializers import register_classes
|
from openlp.plugins.presentations.lib.serializers import register_classes
|
||||||
register_classes()
|
register_classes()
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class MacLOController(PresentationController, LogMixin):
|
class MacLOController(PresentationController, LogMixin):
|
||||||
"""
|
"""
|
||||||
Class to control interactions with MacLO presentations on Mac OS X via Pyro4. It starts the Pyro4 nameserver,
|
Class to control interactions with MacLO presentations on Mac OS X via Pyro5. It starts the Pyro5 nameserver,
|
||||||
starts the LibreOfficeServer, and then controls MacLO via Pyro4.
|
starts the LibreOfficeServer, and then controls MacLO via Pyro5.
|
||||||
"""
|
"""
|
||||||
log.info('MacLOController loaded')
|
log.info('MacLOController loaded')
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class MacLOController(PresentationController, LogMixin):
|
||||||
@property
|
@property
|
||||||
def client(self):
|
def client(self):
|
||||||
"""
|
"""
|
||||||
Set up a Pyro4 client so that we can talk to the LibreOfficeServer
|
Set up a Pyro5 client so that we can talk to the LibreOfficeServer
|
||||||
"""
|
"""
|
||||||
if not self._client:
|
if not self._client:
|
||||||
self._client = Proxy('PYRO:openlp.libreofficeserver@localhost:4310')
|
self._client = Proxy('PYRO:openlp.libreofficeserver@localhost:4310')
|
||||||
|
|
|
@ -19,16 +19,16 @@
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
##########################################################################
|
##########################################################################
|
||||||
"""
|
"""
|
||||||
This module contains some helpers for serializing Path objects in Pyro4
|
This module contains some helpers for serializing Path objects in Pyro5
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from Pyro4.util import SerializerBase
|
from Pyro5.api import SerializerBase
|
||||||
|
|
||||||
|
|
||||||
def path_class_to_dict(obj):
|
def path_class_to_dict(obj):
|
||||||
"""
|
"""
|
||||||
Serialize a Path object for Pyro4
|
Serialize a Path object for Pyro5
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
'__class__': 'Path',
|
'__class__': 'Path',
|
||||||
|
|
|
@ -63,7 +63,7 @@ LINUX_MODULES = [
|
||||||
|
|
||||||
MACOSX_MODULES = [
|
MACOSX_MODULES = [
|
||||||
'objc',
|
'objc',
|
||||||
'Pyro4',
|
'Pyro5',
|
||||||
'AppKit'
|
'AppKit'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -113,7 +113,7 @@ using a computer and a display/projector.""",
|
||||||
'pyobjc-framework-Cocoa; platform_system=="Darwin"',
|
'pyobjc-framework-Cocoa; platform_system=="Darwin"',
|
||||||
'PyQt5 >= 5.12',
|
'PyQt5 >= 5.12',
|
||||||
'PyQtWebEngine',
|
'PyQtWebEngine',
|
||||||
'Pyro4; platform_system=="Darwin"',
|
'Pyro5; platform_system=="Darwin"',
|
||||||
'pywin32; platform_system=="Windows"',
|
'pywin32; platform_system=="Windows"',
|
||||||
'QtAwesome',
|
'QtAwesome',
|
||||||
"qrcode",
|
"qrcode",
|
||||||
|
|
|
@ -25,11 +25,11 @@ from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import Pyro4 # noqa
|
import Pyro5 # noqa
|
||||||
from openlp.plugins.presentations.lib.serializers import path_class_to_dict, path_dict_to_class, register_classes
|
from openlp.plugins.presentations.lib.serializers import path_class_to_dict, path_dict_to_class, register_classes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import pytest
|
import pytest
|
||||||
pytestmark = pytest.mark.skip('Pyro4 not installed')
|
pytestmark = pytest.mark.skip('Pyro5 not installed')
|
||||||
|
|
||||||
|
|
||||||
def test_path_class_to_dict():
|
def test_path_class_to_dict():
|
||||||
|
|
|
@ -28,17 +28,17 @@ import pytest
|
||||||
from openlp.core.common.platform import is_macosx
|
from openlp.core.common.platform import is_macosx
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import Pyro4 # noqa: F401
|
import Pyro5 # noqa: F401
|
||||||
has_pyro4 = True
|
has_pyro5 = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
has_pyro4 = False
|
has_pyro5 = False
|
||||||
|
|
||||||
if has_pyro4:
|
if has_pyro5:
|
||||||
from openlp.plugins.presentations.lib.libreofficeserver import LibreOfficeServer, TextType, main
|
from openlp.plugins.presentations.lib.libreofficeserver import LibreOfficeServer, TextType, main
|
||||||
|
|
||||||
|
|
||||||
pytestmark = [
|
pytestmark = [
|
||||||
pytest.mark.skipif(not has_pyro4, reason='Pyro4 is not installed, skipping testing the LibreOffice server'),
|
pytest.mark.skipif(not has_pyro5, reason='Pyro5 is not installed, skipping testing the LibreOffice server'),
|
||||||
pytest.mark.skipif(not is_macosx(), reason='Not on macOS, skipping testing the LibreOffice server')
|
pytest.mark.skipif(not is_macosx(), reason='Not on macOS, skipping testing the LibreOffice server')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,13 @@ from tests.helpers.testmixin import TestMixin
|
||||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import Pyro4 # noqa: F401
|
import Pyro5 # noqa: F401
|
||||||
has_pyro4 = True
|
has_pyro5 = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
has_pyro4 = False
|
has_pyro5 = False
|
||||||
|
|
||||||
pytestmark = [
|
pytestmark = [
|
||||||
pytest.mark.skipif(not has_pyro4, reason='Pyro4 is not installed, skipping testing the Mac LibreOffice controller'),
|
pytest.mark.skipif(not has_pyro5, reason='Pyro5 is not installed, skipping testing the Mac LibreOffice controller'),
|
||||||
pytest.mark.skipif(not is_macosx(), reason='Not on macOS, skipping testing the Mac LibreOffice controller')
|
pytest.mark.skipif(not is_macosx(), reason='Not on macOS, skipping testing the Mac LibreOffice controller')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue