Merge lp:~raoul-snyman/openlp/ubuntu-vlc-bug into lp:openlp/2.2

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 2566
Proposed branch: lp:~raoul-snyman/openlp/ubuntu-vlc-bug
Merge into: lp:openlp/2.2
Diff against target: 70 lines (+22/-5)
2 files modified
openlp/core/ui/media/vlcplayer.py (+5/-0)
tests/functional/openlp_core_ui_media/test_vlcplayer.py (+17/-5)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/ubuntu-vlc-bug
Reviewer Review Type Date Requested Status
Tomas Groth Approve
Review via email: mp+275936@code.launchpad.net

This proposal supersedes a proposal from 2015-10-27.

Commit message

[Media Players] Added better detection for VLC, with thanks to Tomas.

Description of the change

[Media Players] Added better detection for VLC, with thanks to Tomas.

Note: I made a test, but this is untestable because of the hidden import inside the function.

lp:~raoul-snyman/openlp/ubuntu-vlc-bug (revision 2563)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/1162/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/1085/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/1026/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/873/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/469/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/589/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/460/

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/media/vlcplayer.py'
2--- openlp/core/ui/media/vlcplayer.py 2015-09-04 09:01:07 +0000
3+++ openlp/core/ui/media/vlcplayer.py 2015-10-27 23:51:18 +0000
4@@ -84,7 +84,9 @@
5 pass
6 if is_vlc_available:
7 try:
8+ vlc_instance = vlc.Instance()
9 VERSION = vlc.libvlc_get_version().decode('UTF-8')
10+ vlc_instance.release()
11 except:
12 VERSION = '0.0.0'
13 # LooseVersion does not work when a string contains letter and digits (e. g. 2.0.5 Twoflower).
14@@ -95,6 +97,9 @@
15 if is_vlc_available:
16 return vlc
17 else:
18+ # The vlc module may have been imported. Remove it if it has.
19+ if 'openlp.core.ui.media.vendor.vlc' in sys.modules:
20+ del sys.modules['openlp.core.ui.media.vendor.vlc']
21 return None
22
23
24
25=== modified file 'tests/functional/openlp_core_ui_media/test_vlcplayer.py'
26--- tests/functional/openlp_core_ui_media/test_vlcplayer.py 2015-05-25 20:58:05 +0000
27+++ tests/functional/openlp_core_ui_media/test_vlcplayer.py 2015-10-27 23:51:18 +0000
28@@ -25,7 +25,7 @@
29 import os
30 import sys
31 from datetime import datetime, timedelta
32-from unittest import TestCase
33+from unittest import TestCase, skip
34
35 from openlp.core.common import Registry
36 from openlp.core.ui.media import MediaState, MediaType
37@@ -50,6 +50,22 @@
38 del sys.modules['openlp.core.ui.media.vendor.vlc']
39 MockDateTime.revert()
40
41+ @skip('No way to test this')
42+ @patch('openlp.core.ui.media.vlcplayer.vlc')
43+ def get_vlc_fails_and_removes_module_test(self, mocked_vlc):
44+ """
45+ Test that when the VLC import fails, it removes the module from sys.modules
46+ """
47+ # GIVEN: We're on OS X and we don't have the VLC plugin path set
48+ mocked_vlc.Instance.side_effect = NameError
49+ mocked_vlc.libvlc_get_version.return_value = b'0.0.0'
50+
51+ # WHEN: An checking if the player is available
52+ get_vlc()
53+
54+ # THEN: The extra environment variable should be there
55+ self.assertNotIn('openlp.core.ui.media.vendor.vlc', sys.modules)
56+
57 @patch('openlp.core.ui.media.vlcplayer.is_macosx')
58 def fix_vlc_22_plugin_path_test(self, mocked_is_macosx):
59 """
60@@ -74,10 +90,6 @@
61 """
62 # GIVEN: We're not on OS X and we don't have the VLC plugin path set
63 mocked_is_macosx.return_value = False
64- if 'VLC_PLUGIN_PATH' in os.environ:
65- del os.environ['VLC_PLUGIN_PATH']
66- if 'openlp.core.ui.media.vendor.vlc' in sys.modules:
67- del sys.modules['openlp.core.ui.media.vendor.vlc']
68
69 # WHEN: An checking if the player is available
70 get_vlc()

Subscribers

People subscribed via source and target branches

to all changes: