Merge lp:~phill-ridout/openlp/fixes-mkIV into lp:openlp

Proposed by Phill
Status: Merged
Merged at revision: 2794
Proposed branch: lp:~phill-ridout/openlp/fixes-mkIV
Merge into: lp:openlp
Diff against target: 390 lines (+96/-43)
12 files modified
openlp/core/api/deploy.py (+2/-0)
openlp/core/api/http/server.py (+4/-1)
openlp/core/app.py (+2/-2)
openlp/core/common/settings.py (+1/-1)
openlp/core/ui/media/mediacontroller.py (+3/-5)
openlp/core/ui/media/vlcplayer.py (+6/-5)
openlp/core/ui/servicemanager.py (+7/-3)
openlp/plugins/media/forms/mediaclipselectorform.py (+7/-6)
openlp/plugins/media/lib/mediaitem.py (+4/-5)
tests/functional/openlp_core/lib/test_exceptions.py (+45/-0)
tests/functional/openlp_core/lib/test_mediamanageritem.py (+9/-9)
tests/functional/openlp_core/ui/media/test_vlcplayer.py (+6/-6)
To merge this branch: bzr merge lp:~phill-ridout/openlp/fixes-mkIV
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Raoul Snyman Approve
Review via email: mp+334708@code.launchpad.net

Description of the change

A few various fixes, including some affecting the creation / saving of services.

Add this to your merge proposal:
--------------------------------------------------------------------------------
lp:~phill-ridout/openlp/fixes-mkIV (revision 2798)
https://ci.openlp.io/job/Branch-01-Pull/2337/ [WAITING]
[RUNNING]
[SUCCESS]
https://ci.openlp.io/job/Branch-02-Functional-Tests/2238/ [WAITING]
[RUNNING]
[SUCCESS]
https://ci.openlp.io/job/Branch-03-Interface-Tests/2108/ [WAITING]
[RUNNING]
[SUCCESS]
https://ci.openlp.io/job/Branch-04a-Code_Analysis/1434/ [WAITING]
[RUNNING]
[SUCCESS]
https://ci.openlp.io/job/Branch-04b-Test_Coverage/1253/ [WAITING]
[RUNNING]
[SUCCESS]
https://ci.openlp.io/job/Branch-04c-Code_Analysis2/383/ [WAITING]
[RUNNING]
[SUCCESS]
https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/212/ [WAITING]
[RUNNING]
[FAILURE]
Stopping after failure

Failed builds:
 - Branch-05-AppVeyor-Tests #212: https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/212/console

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

see inline

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
Revision history for this message
Tim Bentley (trb143) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/api/deploy.py'
2--- openlp/core/api/deploy.py 2017-11-18 11:23:15 +0000
3+++ openlp/core/api/deploy.py 2017-12-04 21:51:22 +0000
4@@ -52,6 +52,8 @@
5 web_config = get_web_page('https://get.openlp.org/webclient/download.cfg', headers={'User-Agent': user_agent})
6 except ConnectionError:
7 return False
8+ if not web_config:
9+ return None
10 file_bits = web_config.split()
11 return file_bits[0], file_bits[2]
12
13
14=== modified file 'openlp/core/api/http/server.py'
15--- openlp/core/api/http/server.py 2017-12-02 09:11:22 +0000
16+++ openlp/core/api/http/server.py 2017-12-04 21:51:22 +0000
17@@ -67,7 +67,10 @@
18 address = Settings().value('api/ip address')
19 port = Settings().value('api/port')
20 Registry().execute('get_website_version')
21- serve(application, host=address, port=port)
22+ try:
23+ serve(application, host=address, port=port)
24+ except OSError:
25+ log.exception('An error occurred when serving the application.')
26
27 def stop(self):
28 pass
29
30=== modified file 'openlp/core/app.py'
31--- openlp/core/app.py 2017-10-23 22:09:57 +0000
32+++ openlp/core/app.py 2017-12-04 21:51:22 +0000
33@@ -403,8 +403,8 @@
34 .format(back_up_path=back_up_path))
35 QtWidgets.QMessageBox.information(
36 None, translate('OpenLP', 'Settings Upgrade'),
37- translate('OpenLP', 'Your settings are about to upgraded. A backup will be created at {back_up_path}')
38- .format(back_up_path=back_up_path))
39+ translate('OpenLP', 'Your settings are about to be upgraded. A backup will be created at '
40+ '{back_up_path}').format(back_up_path=back_up_path))
41 settings.export(back_up_path)
42 settings.upgrade_settings()
43 # First time checks in settings
44
45=== modified file 'openlp/core/common/settings.py'
46--- openlp/core/common/settings.py 2017-11-16 00:19:26 +0000
47+++ openlp/core/common/settings.py 2017-12-04 21:51:22 +0000
48@@ -236,7 +236,7 @@
49 ('bibles/last search type', '', []),
50 ('custom/last search type', 'custom/last used search type', []),
51 # The following changes are being made for the conversion to using Path objects made in 2.6 development
52- ('advanced/data path', 'advanced/data path', [(str_to_path, None)]),
53+ ('advanced/data path', 'advanced/data path', [(lambda p: Path(p) if p is not None else None, None)]),
54 ('crashreport/last directory', 'crashreport/last directory', [(str_to_path, None)]),
55 ('servicemanager/last directory', 'servicemanager/last directory', [(str_to_path, None)]),
56 ('servicemanager/last file', 'servicemanager/last file', [(str_to_path, None)]),
57
58=== modified file 'openlp/core/ui/media/mediacontroller.py'
59--- openlp/core/ui/media/mediacontroller.py 2017-10-23 22:09:57 +0000
60+++ openlp/core/ui/media/mediacontroller.py 2017-12-04 21:51:22 +0000
61@@ -498,8 +498,6 @@
62 :param controller: The media controller.
63 :return: True if setup succeeded else False.
64 """
65- if controller is None:
66- controller = self.display_controllers[DisplayControllerType.Plugin]
67 # stop running videos
68 self.media_reset(controller)
69 # Setup media info
70@@ -509,9 +507,9 @@
71 controller.media_info.media_type = MediaType.CD
72 else:
73 controller.media_info.media_type = MediaType.DVD
74- controller.media_info.start_time = start // 1000
75- controller.media_info.end_time = end // 1000
76- controller.media_info.length = (end - start) // 1000
77+ controller.media_info.start_time = start
78+ controller.media_info.end_time = end
79+ controller.media_info.length = (end - start)
80 controller.media_info.title_track = title
81 controller.media_info.audio_track = audio_track
82 controller.media_info.subtitle_track = subtitle_track
83
84=== modified file 'openlp/core/ui/media/vlcplayer.py'
85--- openlp/core/ui/media/vlcplayer.py 2017-10-07 07:05:07 +0000
86+++ openlp/core/ui/media/vlcplayer.py 2017-12-04 21:51:22 +0000
87@@ -280,7 +280,8 @@
88 start_time = controller.media_info.start_time
89 log.debug('mediatype: ' + str(controller.media_info.media_type))
90 # Set tracks for the optical device
91- if controller.media_info.media_type == MediaType.DVD:
92+ if controller.media_info.media_type == MediaType.DVD and \
93+ self.get_live_state() != MediaState.Paused and self.get_preview_state() != MediaState.Paused:
94 log.debug('vlc play, playing started')
95 if controller.media_info.title_track > 0:
96 log.debug('vlc play, title_track set: ' + str(controller.media_info.title_track))
97@@ -350,7 +351,7 @@
98 """
99 if display.controller.media_info.media_type == MediaType.CD \
100 or display.controller.media_info.media_type == MediaType.DVD:
101- seek_value += int(display.controller.media_info.start_time * 1000)
102+ seek_value += int(display.controller.media_info.start_time)
103 if display.vlc_media_player.is_seekable():
104 display.vlc_media_player.set_time(seek_value)
105
106@@ -386,15 +387,15 @@
107 self.stop(display)
108 controller = display.controller
109 if controller.media_info.end_time > 0:
110- if display.vlc_media_player.get_time() > controller.media_info.end_time * 1000:
111+ if display.vlc_media_player.get_time() > controller.media_info.end_time:
112 self.stop(display)
113 self.set_visible(display, False)
114 if not controller.seek_slider.isSliderDown():
115 controller.seek_slider.blockSignals(True)
116 if display.controller.media_info.media_type == MediaType.CD \
117 or display.controller.media_info.media_type == MediaType.DVD:
118- controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time() -
119- int(display.controller.media_info.start_time * 1000))
120+ controller.seek_slider.setSliderPosition(
121+ display.vlc_media_player.get_time() - int(display.controller.media_info.start_time))
122 else:
123 controller.seek_slider.setSliderPosition(display.vlc_media_player.get_time())
124 controller.seek_slider.blockSignals(False)
125
126=== modified file 'openlp/core/ui/servicemanager.py'
127--- openlp/core/ui/servicemanager.py 2017-11-19 21:57:38 +0000
128+++ openlp/core/ui/servicemanager.py 2017-12-04 21:51:22 +0000
129@@ -350,7 +350,10 @@
130 if modified:
131 self.service_id += 1
132 self._modified = modified
133- service_file = self.short_file_name() or translate('OpenLP.ServiceManager', 'Untitled Service')
134+ if self._service_path:
135+ service_file = self._service_path.name
136+ else:
137+ service_file = translate('OpenLP.ServiceManager', 'Untitled Service')
138 self.main_window.set_service_modified(modified, service_file)
139
140 def is_modified(self):
141@@ -367,7 +370,7 @@
142 :rtype: None
143 """
144 self._service_path = file_path
145- self.main_window.set_service_modified(self.is_modified(), self.short_file_name())
146+ self.main_window.set_service_modified(self.is_modified(), file_path.name)
147 Settings().setValue('servicemanager/last file', file_path)
148 if file_path and file_path.suffix == '.oszl':
149 self._save_lite = True
150@@ -386,7 +389,8 @@
151 """
152 Return the current file name, excluding the path.
153 """
154- return self._service_path.name
155+ if self._service_path:
156+ return self._service_path.name
157
158 def reset_supported_suffixes(self):
159 """
160
161=== modified file 'openlp/plugins/media/forms/mediaclipselectorform.py'
162--- openlp/plugins/media/forms/mediaclipselectorform.py 2017-10-23 22:09:57 +0000
163+++ openlp/plugins/media/forms/mediaclipselectorform.py 2017-12-04 21:51:22 +0000
164@@ -28,6 +28,7 @@
165 from PyQt5 import QtCore, QtGui, QtWidgets
166
167 from openlp.core.common import is_win, is_linux, is_macosx
168+from openlp.core.common.path import Path
169 from openlp.core.common.i18n import translate
170 from openlp.core.common.mixins import RegistryProperties
171 from openlp.plugins.media.forms.mediaclipselectordialog import Ui_MediaClipSelector
172@@ -109,7 +110,7 @@
173 self.subtitle_tracks_combobox.clear()
174 self.audio_tracks_combobox.clear()
175 self.titles_combo_box.clear()
176- time = QtCore.QTime()
177+ time = QtCore.QTime(0, 0, 0)
178 self.start_position_edit.setTime(time)
179 self.end_timeedit.setTime(time)
180 self.position_timeedit.setTime(time)
181@@ -294,7 +295,7 @@
182 :param clicked: Given from signal, not used.
183 """
184 vlc_ms_pos = self.vlc_media_player.get_time()
185- time = QtCore.QTime()
186+ time = QtCore.QTime(0, 0, 0)
187 new_pos_time = time.addMSecs(vlc_ms_pos)
188 self.start_position_edit.setTime(new_pos_time)
189 # If start time is after end time, update end time.
190@@ -310,7 +311,7 @@
191 :param clicked: Given from signal, not used.
192 """
193 vlc_ms_pos = self.vlc_media_player.get_time()
194- time = QtCore.QTime()
195+ time = QtCore.QTime(0, 0, 0)
196 new_pos_time = time.addMSecs(vlc_ms_pos)
197 self.end_timeedit.setTime(new_pos_time)
198 # If start time is after end time, update start time.
199@@ -447,7 +448,7 @@
200 self.position_slider.setMaximum(self.playback_length)
201 # setup start and end time
202 rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0)
203- time = QtCore.QTime()
204+ time = QtCore.QTime(0, 0, 0)
205 playback_length_time = time.addMSecs(rounded_vlc_ms_length)
206 self.start_position_edit.setMaximumTime(playback_length_time)
207 self.end_timeedit.setMaximumTime(playback_length_time)
208@@ -505,7 +506,7 @@
209 if self.vlc_media_player:
210 vlc_ms_pos = self.vlc_media_player.get_time()
211 rounded_vlc_ms_pos = int(round(vlc_ms_pos / 100.0) * 100.0)
212- time = QtCore.QTime()
213+ time = QtCore.QTime(0, 0, 0)
214 new_pos_time = time.addMSecs(rounded_vlc_ms_pos)
215 self.position_timeedit.setTime(new_pos_time)
216 self.position_slider.setSliderPosition(vlc_ms_pos)
217@@ -615,7 +616,7 @@
218 break
219 # Append the new name to the optical string and the path
220 optical += new_optical_name + ':' + path
221- self.media_item.add_optical_clip(optical)
222+ self.media_item.add_optical_clip(Path(optical))
223
224 def media_state_wait(self, media_state):
225 """
226
227=== modified file 'openlp/plugins/media/lib/mediaitem.py'
228--- openlp/plugins/media/lib/mediaitem.py 2017-11-14 17:35:37 +0000
229+++ openlp/plugins/media/lib/mediaitem.py 2017-12-04 21:51:22 +0000
230@@ -269,10 +269,9 @@
231 service_item.add_from_command(filename, name, CLAPPERBOARD)
232 service_item.title = clip_name
233 # Set the length
234- self.media_controller.media_setup_optical(name, title, audio_track, subtitle_track, start, end, None, None)
235- service_item.set_media_length((end - start) / 1000)
236- service_item.start_time = start / 1000
237- service_item.end_time = end / 1000
238+ service_item.set_media_length(end - start)
239+ service_item.start_time = start
240+ service_item.end_time = end
241 service_item.add_capability(ItemCapabilities.IsOptical)
242 else:
243 if not os.path.exists(filename):
244@@ -455,5 +454,5 @@
245 return
246 # Append the optical string to the media list
247 file_paths.append(optical)
248- self.load_list([optical])
249+ self.load_list([str(optical)])
250 Settings().setValue(self.settings_section + '/media files', file_paths)
251
252=== added file 'tests/functional/openlp_core/lib/test_exceptions.py'
253--- tests/functional/openlp_core/lib/test_exceptions.py 1970-01-01 00:00:00 +0000
254+++ tests/functional/openlp_core/lib/test_exceptions.py 2017-12-04 21:51:22 +0000
255@@ -0,0 +1,45 @@
256+# -*- coding: utf-8 -*-
257+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
258+
259+###############################################################################
260+# OpenLP - Open Source Lyrics Projection #
261+# --------------------------------------------------------------------------- #
262+# Copyright (c) 2008-2017 OpenLP Developers #
263+# --------------------------------------------------------------------------- #
264+# This program is free software; you can redistribute it and/or modify it #
265+# under the terms of the GNU General Public License as published by the Free #
266+# Software Foundation; version 2 of the License. #
267+# #
268+# This program is distributed in the hope that it will be useful, but WITHOUT #
269+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
270+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
271+# more details. #
272+# #
273+# You should have received a copy of the GNU General Public License along #
274+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
275+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
276+###############################################################################
277+"""
278+Package to test the openlp.core.lib.exceptions package.
279+"""
280+from unittest import TestCase
281+
282+from openlp.core.lib.exceptions import ValidationError
283+
284+
285+class TestValidationError(TestCase):
286+ """
287+ Test the ValidationError Class
288+ """
289+ def test_validation_error(self):
290+ """
291+ Test the creation of a ValidationError
292+ """
293+ # GIVEN: The ValidationError class
294+
295+ # WHEN: Creating an instance of ValidationError
296+ error = ValidationError('Test ValidationError')
297+
298+ # THEN: Then calling str on the error should return the correct text and it should be an instance of `Exception`
299+ assert str(error) == 'Test ValidationError'
300+ assert isinstance(error, Exception)
301
302=== modified file 'tests/functional/openlp_core/lib/test_mediamanageritem.py'
303--- tests/functional/openlp_core/lib/test_mediamanageritem.py 2017-04-24 05:17:55 +0000
304+++ tests/functional/openlp_core/lib/test_mediamanageritem.py 2017-12-04 21:51:22 +0000
305@@ -42,8 +42,8 @@
306 self.mocked_setup = self.setup_patcher.start()
307 self.addCleanup(self.setup_patcher.stop)
308
309- @patch(u'openlp.core.lib.mediamanageritem.Settings')
310- @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
311+ @patch('openlp.core.lib.mediamanageritem.Settings')
312+ @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
313 def test_on_double_clicked(self, mocked_on_preview_click, MockedSettings):
314 """
315 Test that when an item is double-clicked then the item is previewed
316@@ -75,8 +75,8 @@
317 self.assertTrue(mmi.has_delete_icon, 'By default a delete icon should be present')
318 self.assertFalse(mmi.add_to_service_item, 'There should be no add_to_service icon by default')
319
320- @patch(u'openlp.core.lib.mediamanageritem.Settings')
321- @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
322+ @patch('openlp.core.lib.mediamanageritem.Settings')
323+ @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
324 def test_on_double_clicked_go_live(self, mocked_on_live_click, MockedSettings):
325 """
326 Test that when "Double-click to go live" is enabled that the item goes live
327@@ -93,9 +93,9 @@
328 # THEN: on_live_click() should have been called
329 mocked_on_live_click.assert_called_with()
330
331- @patch(u'openlp.core.lib.mediamanageritem.Settings')
332- @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
333- @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
334+ @patch('openlp.core.lib.mediamanageritem.Settings')
335+ @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
336+ @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
337 def test_on_double_clicked_single_click_preview(self, mocked_on_preview_click, mocked_on_live_click,
338 MockedSettings):
339 """
340@@ -111,5 +111,5 @@
341 mmi.on_double_clicked()
342
343 # THEN: on_live_click() should have been called
344- self.assertEqual(0, mocked_on_live_click.call_count, u'on_live_click() should not have been called')
345- self.assertEqual(0, mocked_on_preview_click.call_count, u'on_preview_click() should not have been called')
346+ self.assertEqual(0, mocked_on_live_click.call_count, 'on_live_click() should not have been called')
347+ self.assertEqual(0, mocked_on_preview_click.call_count, 'on_preview_click() should not have been called')
348
349=== modified file 'tests/functional/openlp_core/ui/media/test_vlcplayer.py'
350--- tests/functional/openlp_core/ui/media/test_vlcplayer.py 2017-10-07 07:05:07 +0000
351+++ tests/functional/openlp_core/ui/media/test_vlcplayer.py 2017-12-04 21:51:22 +0000
352@@ -693,9 +693,9 @@
353 vlc_player.set_state(MediaState.Paused, mocked_display)
354
355 # WHEN: play() is called
356- with patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait, \
357- patch.object(vlc_player, 'volume') as mocked_volume:
358- mocked_media_state_wait.return_value = True
359+ with patch.object(vlc_player, 'media_state_wait', return_value=True) as mocked_media_state_wait, \
360+ patch.object(vlc_player, 'volume') as mocked_volume, \
361+ patch.object(vlc_player, 'get_live_state', return_value=MediaState.Loaded):
362 result = vlc_player.play(mocked_display)
363
364 # THEN: A bunch of things should happen to play the media
365@@ -872,7 +872,7 @@
366 mocked_display = MagicMock()
367 mocked_display.controller.media_info.media_type = MediaType.DVD
368 mocked_display.vlc_media_player.is_seekable.return_value = True
369- mocked_display.controller.media_info.start_time = 3
370+ mocked_display.controller.media_info.start_time = 3000
371 vlc_player = VlcPlayer(None)
372
373 # WHEN: seek() is called
374@@ -976,7 +976,7 @@
375 mocked_display = MagicMock()
376 mocked_display.controller = mocked_controller
377 mocked_display.vlc_media.get_state.return_value = 1
378- mocked_display.vlc_media_player.get_time.return_value = 400000
379+ mocked_display.vlc_media_player.get_time.return_value = 400
380 mocked_display.controller.media_info.media_type = MediaType.DVD
381 vlc_player = VlcPlayer(None)
382
383@@ -990,7 +990,7 @@
384 self.assertEqual(2, mocked_stop.call_count)
385 mocked_display.vlc_media_player.get_time.assert_called_with()
386 mocked_set_visible.assert_called_with(mocked_display, False)
387- mocked_controller.seek_slider.setSliderPosition.assert_called_with(300000)
388+ mocked_controller.seek_slider.setSliderPosition.assert_called_with(300)
389 expected_calls = [call(True), call(False)]
390 self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list)
391