gst1: Move all gi imports to a helper module
This commit is contained in:
parent
b143898cd3
commit
d9f53d5da3
@ -4,26 +4,8 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
|
||||||
|
|
||||||
try:
|
from mopidy.internal.gi import Gst # noqa: Import to initialize
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import Gst
|
|
||||||
except ImportError:
|
|
||||||
print(textwrap.dedent("""
|
|
||||||
ERROR: The GStreamer Python package was not found.
|
|
||||||
|
|
||||||
Mopidy requires GStreamer to work. GStreamer is a C library with a
|
|
||||||
number of dependencies itself, and cannot be installed with the regular
|
|
||||||
Python tools like pip.
|
|
||||||
|
|
||||||
Please see http://docs.mopidy.com/en/latest/installation/ for
|
|
||||||
instructions on how to install the required dependencies.
|
|
||||||
"""))
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
Gst.init()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Make GObject's mainloop the event loop for python-dbus
|
# Make GObject's mainloop the event loop for python-dbus
|
||||||
|
|||||||
@ -4,12 +4,6 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
gi.require_version('GstPbutils', '1.0')
|
|
||||||
from gi.repository import GObject, Gst, GstPbutils
|
|
||||||
Gst.is_initialized() or Gst.init()
|
|
||||||
|
|
||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
from mopidy import exceptions
|
from mopidy import exceptions
|
||||||
@ -17,6 +11,7 @@ from mopidy.audio import tags as tags_lib, utils
|
|||||||
from mopidy.audio.constants import PlaybackState
|
from mopidy.audio.constants import PlaybackState
|
||||||
from mopidy.audio.listener import AudioListener
|
from mopidy.audio.listener import AudioListener
|
||||||
from mopidy.internal import deprecation, process
|
from mopidy.internal import deprecation, process
|
||||||
|
from mopidy.internal.gi import GObject, Gst, GstPbutils
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -4,15 +4,10 @@ from __future__ import (
|
|||||||
import collections
|
import collections
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
gi.require_version('GstPbutils', '1.0')
|
|
||||||
from gi.repository import Gst, GstPbutils
|
|
||||||
Gst.is_initialized() or Gst.init()
|
|
||||||
|
|
||||||
from mopidy import exceptions
|
from mopidy import exceptions
|
||||||
from mopidy.audio import tags as tags_lib, utils
|
from mopidy.audio import tags as tags_lib, utils
|
||||||
from mopidy.internal import encoding
|
from mopidy.internal import encoding
|
||||||
|
from mopidy.internal.gi import Gst, GstPbutils
|
||||||
|
|
||||||
# GST_ELEMENT_FACTORY_LIST:
|
# GST_ELEMENT_FACTORY_LIST:
|
||||||
_DECODER = 1 << 0
|
_DECODER = 1 << 0
|
||||||
|
|||||||
@ -5,13 +5,9 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import numbers
|
import numbers
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import GLib, Gst
|
|
||||||
Gst.is_initialized() or Gst.init()
|
|
||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat
|
||||||
from mopidy.internal import log
|
from mopidy.internal import log
|
||||||
|
from mopidy.internal.gi import GLib, Gst
|
||||||
from mopidy.models import Album, Artist, Track
|
from mopidy.models import Album, Artist, Track
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import Gst
|
|
||||||
|
|
||||||
from mopidy import httpclient
|
from mopidy import httpclient
|
||||||
|
from mopidy.internal.gi import Gst
|
||||||
|
|
||||||
|
|
||||||
def calculate_duration(num_samples, sample_rate):
|
def calculate_duration(num_samples, sample_rate):
|
||||||
|
|||||||
@ -5,14 +5,10 @@ import os
|
|||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import Gst
|
|
||||||
Gst.is_initialized() or Gst.init()
|
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from mopidy.internal import formatting
|
from mopidy.internal import formatting
|
||||||
|
from mopidy.internal.gi import Gst, gi
|
||||||
|
|
||||||
|
|
||||||
def format_dependency_list(adapters=None):
|
def format_dependency_list(adapters=None):
|
||||||
|
|||||||
33
mopidy/internal/gi.py
Normal file
33
mopidy/internal/gi.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
import gi
|
||||||
|
gi.require_version('Gst', '1.0')
|
||||||
|
gi.require_version('GstPbutils', '1.0')
|
||||||
|
from gi.repository import GLib, GObject, Gst, GstPbutils
|
||||||
|
except ImportError:
|
||||||
|
print(textwrap.dedent("""
|
||||||
|
ERROR: A GObject Python package was not found.
|
||||||
|
|
||||||
|
Mopidy requires GStreamer to work. GStreamer is a C library with a
|
||||||
|
number of dependencies itself, and cannot be installed with the regular
|
||||||
|
Python tools like pip.
|
||||||
|
|
||||||
|
Please see http://docs.mopidy.com/en/latest/installation/ for
|
||||||
|
instructions on how to install the required dependencies.
|
||||||
|
"""))
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
Gst.is_initialized() or Gst.init()
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'GLib',
|
||||||
|
'GObject',
|
||||||
|
'Gst',
|
||||||
|
'GstPbutils',
|
||||||
|
'gi',
|
||||||
|
]
|
||||||
@ -3,10 +3,6 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
import threading
|
import threading
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import Gst
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import pykka
|
import pykka
|
||||||
@ -14,6 +10,7 @@ import pykka
|
|||||||
from mopidy import audio
|
from mopidy import audio
|
||||||
from mopidy.audio.constants import PlaybackState
|
from mopidy.audio.constants import PlaybackState
|
||||||
from mopidy.internal import path
|
from mopidy.internal import path
|
||||||
|
from mopidy.internal.gi import Gst
|
||||||
|
|
||||||
from tests import dummy_audio, path_to_data_dir
|
from tests import dummy_audio, path_to_data_dir
|
||||||
|
|
||||||
|
|||||||
@ -4,12 +4,9 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import GLib, GObject, Gst
|
|
||||||
|
|
||||||
from mopidy import compat
|
from mopidy import compat
|
||||||
from mopidy.audio import tags
|
from mopidy.audio import tags
|
||||||
|
from mopidy.internal.gi import GLib, GObject, Gst
|
||||||
from mopidy.models import Album, Artist, Track
|
from mopidy.models import Album, Artist, Track
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import Gst
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mopidy.audio import utils
|
from mopidy.audio import utils
|
||||||
|
from mopidy.internal.gi import Gst
|
||||||
|
|
||||||
|
|
||||||
class TestCreateBuffer(object):
|
class TestCreateBuffer(object):
|
||||||
|
|||||||
@ -4,15 +4,12 @@ import platform
|
|||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version('Gst', '1.0')
|
|
||||||
from gi.repository import Gst
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from mopidy.internal import deps
|
from mopidy.internal import deps
|
||||||
|
from mopidy.internal.gi import Gst, gi
|
||||||
|
|
||||||
|
|
||||||
class DepsTest(unittest.TestCase):
|
class DepsTest(unittest.TestCase):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user