Merge lp:~alisonken1/openlp/pjlink2-u into lp:openlp
- pjlink2-u
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~alisonken1/openlp/pjlink2-u |
Merge into: | lp:openlp |
Diff against target: |
350 lines (+59/-47) 11 files modified
openlp/core/projectors/db.py (+7/-1) openlp/core/projectors/manager.py (+13/-28) openlp/core/projectors/pjlink.py (+15/-4) openlp/core/ui/icons.py (+8/-4) setup.cfg (+1/-0) tests/functional/openlp_core/lib/test_image_manager.py (+2/-2) tests/functional/openlp_plugins/media/test_mediaplugin.py (+1/-1) tests/functional/openlp_plugins/songs/test_lib.py (+1/-1) tests/functional/openlp_plugins/songusage/test_songusage.py (+2/-2) tests/openlp_core/projectors/test_projector_db.py (+4/-3) tests/openlp_core/projectors/test_projector_pjlink_commands_01.py (+5/-1) |
To merge this branch: | bzr merge lp:~alisonken1/openlp/pjlink2-u |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenLP Core | Pending | ||
Review via email: mp+364153@code.launchpad.net |
This proposal supersedes a proposal from 2019-03-08.
This proposal has been superseded by a proposal from 2019-03-08.
Commit message
PJLink2 Update U
Description of the change
- Fix projector S_ON status icon selection
- Remove unused status items (status icons changed to FA)
- Fix projector icon status update for network errors
(keep error icon until network reconnects rather than disconnect icon)
- Fix colors to projector toolbar connect/power icons
- Fix toolbar select input icon not always enabled after selecting/
- Add max-line-length option for flake8 tests in setup.cfg
- Fix projector tests
-------
lp:~alisonken1/openlp/pjlink2-u (revision 2849)
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/
Ken Roberts (alisonken1) wrote : Posted in a previous version of this proposal | # |
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
Linux tests passed!
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
Linting passed!
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
macOS tests failed, please see https:/
Raoul Snyman (raoul-snyman) wrote : | # |
Linux tests passed!
Raoul Snyman (raoul-snyman) wrote : | # |
Linting passed!
Raoul Snyman (raoul-snyman) wrote : | # |
macOS tests failed, please see https:/
Phill (phill-ridout) wrote : Posted in a previous version of this proposal | # |
Few minor inlines.
- 2849. By Ken Roberts
-
PJLink2 Update U
- 2850. By Ken Roberts
-
Minor cleanups
Unmerged revisions
Preview Diff
1 | === modified file 'openlp/core/projectors/db.py' |
2 | --- openlp/core/projectors/db.py 2019-02-14 15:09:09 +0000 |
3 | +++ openlp/core/projectors/db.py 2019-03-08 15:20:31 +0000 |
4 | @@ -417,11 +417,17 @@ |
5 | value: (str) From ProjectorSource, Sources tables or PJLink default code list |
6 | """ |
7 | source_dict = {} |
8 | + # Apparently, there was a change to the projector object. Test for which object has db id |
9 | + if hasattr(projector, "id"): |
10 | + chk = projector.id |
11 | + elif hasattr(projector.entry, "id"): |
12 | + chk = projector.entry.id |
13 | + |
14 | # Get default list first |
15 | for key in projector.source_available: |
16 | item = self.get_object_filtered(ProjectorSource, |
17 | and_(ProjectorSource.code == key, |
18 | - ProjectorSource.projector_id == projector.id)) |
19 | + ProjectorSource.projector_id == chk)) |
20 | if item is None: |
21 | source_dict[key] = PJLINK_DEFAULT_CODES[key] |
22 | else: |
23 | |
24 | === modified file 'openlp/core/projectors/manager.py' |
25 | --- openlp/core/projectors/manager.py 2019-02-14 15:09:09 +0000 |
26 | +++ openlp/core/projectors/manager.py 2019-03-08 15:20:31 +0000 |
27 | @@ -46,31 +46,10 @@ |
28 | from openlp.core.ui.icons import UiIcons |
29 | from openlp.core.widgets.toolbar import OpenLPToolbar |
30 | |
31 | - |
32 | log = logging.getLogger(__name__) |
33 | log.debug('projectormanager loaded') |
34 | |
35 | |
36 | -# Dict for matching projector status to display icon |
37 | -STATUS_ICONS = { |
38 | - S_NOT_CONNECTED: ':/projector/projector_item_disconnect.png', |
39 | - S_CONNECTING: ':/projector/projector_item_connect.png', |
40 | - S_CONNECTED: ':/projector/projector_off.png', |
41 | - S_OFF: ':/projector/projector_off.png', |
42 | - S_INITIALIZE: ':/projector/projector_off.png', |
43 | - S_STANDBY: ':/projector/projector_off.png', |
44 | - S_WARMUP: ':/projector/projector_warmup.png', |
45 | - S_ON: ':/projector/projector_on.png', |
46 | - S_COOLDOWN: ':/projector/projector_cooldown.png', |
47 | - E_ERROR: ':/projector/projector_error.png', |
48 | - E_NETWORK: ':/projector/projector_not_connected_error.png', |
49 | - E_SOCKET_TIMEOUT: ':/projector/projector_not_connected_error.png', |
50 | - E_AUTHENTICATION: ':/projector/projector_not_connected_error.png', |
51 | - E_UNKNOWN_SOCKET_ERROR: ':/projector/projector_not_connected_error.png', |
52 | - E_NOT_CONNECTED: ':/projector/projector_not_connected_error.png' |
53 | -} |
54 | - |
55 | - |
56 | class UiProjectorManager(object): |
57 | """ |
58 | UI part of the Projector Manager |
59 | @@ -122,7 +101,7 @@ |
60 | self.one_toolbar.add_toolbar_action('connect_projector', |
61 | text=translate('OpenLP.ProjectorManager', |
62 | 'Connect to selected projector.'), |
63 | - icon=UiIcons().projector_connect, |
64 | + icon=UiIcons().projector_select_connect, |
65 | tooltip=translate('OpenLP.ProjectorManager', |
66 | 'Connect to selected projector.'), |
67 | triggers=self.on_connect_projector) |
68 | @@ -136,7 +115,7 @@ |
69 | self.one_toolbar.add_toolbar_action('disconnect_projector', |
70 | text=translate('OpenLP.ProjectorManager', |
71 | 'Disconnect from selected projectors'), |
72 | - icon=UiIcons().projector_disconnect, |
73 | + icon=UiIcons().projector_select_disconnect, |
74 | tooltip=translate('OpenLP.ProjectorManager', |
75 | 'Disconnect from selected projector.'), |
76 | triggers=self.on_disconnect_projector) |
77 | @@ -151,7 +130,7 @@ |
78 | self.one_toolbar.add_toolbar_action('poweron_projector', |
79 | text=translate('OpenLP.ProjectorManager', |
80 | 'Power on selected projector'), |
81 | - icon=UiIcons().projector_on, |
82 | + icon=UiIcons().projector_power_on, |
83 | tooltip=translate('OpenLP.ProjectorManager', |
84 | 'Power on selected projector.'), |
85 | triggers=self.on_poweron_projector) |
86 | @@ -164,7 +143,7 @@ |
87 | triggers=self.on_poweron_projector) |
88 | self.one_toolbar.add_toolbar_action('poweroff_projector', |
89 | text=translate('OpenLP.ProjectorManager', 'Standby selected projector'), |
90 | - icon=UiIcons().projector_off, |
91 | + icon=UiIcons().projector_power_off, |
92 | tooltip=translate('OpenLP.ProjectorManager', |
93 | 'Put selected projector in standby.'), |
94 | triggers=self.on_poweroff_projector) |
95 | @@ -309,7 +288,7 @@ |
96 | S_INITIALIZE: UiIcons().projector_on, |
97 | S_STANDBY: UiIcons().projector_off, |
98 | S_WARMUP: UiIcons().projector_warmup, |
99 | - S_ON: UiIcons().projector_off, |
100 | + S_ON: UiIcons().projector_on, |
101 | S_COOLDOWN: UiIcons().projector_cooldown, |
102 | E_ERROR: UiIcons().projector_error, |
103 | E_NETWORK: UiIcons().error, |
104 | @@ -505,7 +484,8 @@ |
105 | projector = list_item.data(QtCore.Qt.UserRole) |
106 | try: |
107 | projector.link.connect_to_host() |
108 | - except Exception: |
109 | + except Exception as e: |
110 | + print(e) |
111 | continue |
112 | |
113 | def on_delete_projector(self, opt=None): |
114 | @@ -880,6 +860,7 @@ |
115 | """ |
116 | Update the icons when the selected projectors change |
117 | """ |
118 | + log.debug('update_icons(): Checking for selected projector items in list') |
119 | count = len(self.projector_list_widget.selectedItems()) |
120 | projector = None |
121 | if count == 0: |
122 | @@ -900,6 +881,7 @@ |
123 | self.get_toolbar_item('blank_projector_multiple', hidden=True) |
124 | self.get_toolbar_item('show_projector_multiple', hidden=True) |
125 | elif count == 1: |
126 | + log.debug('update_icons(): Found one item selected') |
127 | projector = self.projector_list_widget.selectedItems()[0].data(QtCore.Qt.UserRole) |
128 | connected = QSOCKET_STATE[projector.link.state()] == S_CONNECTED |
129 | power = projector.link.power == S_ON |
130 | @@ -910,12 +892,14 @@ |
131 | self.get_toolbar_item('blank_projector_multiple', hidden=True) |
132 | self.get_toolbar_item('show_projector_multiple', hidden=True) |
133 | if connected: |
134 | + log.debug('update_icons(): Updating icons for connected state') |
135 | self.get_toolbar_item('view_projector', enabled=True) |
136 | self.get_toolbar_item('source_view_projector', |
137 | - enabled=connected and power and projector.link.source_available is not None) |
138 | + enabled=projector.link.source_available is not None and connected and power) |
139 | self.get_toolbar_item('edit_projector', hidden=True) |
140 | self.get_toolbar_item('delete_projector', hidden=True) |
141 | else: |
142 | + log.debug('update_icons(): Updating for not connected state') |
143 | self.get_toolbar_item('view_projector', hidden=True) |
144 | self.get_toolbar_item('source_view_projector', hidden=True) |
145 | self.get_toolbar_item('edit_projector', enabled=True) |
146 | @@ -931,6 +915,7 @@ |
147 | self.get_toolbar_item('blank_projector', enabled=False) |
148 | self.get_toolbar_item('show_projector', enabled=False) |
149 | else: |
150 | + log.debug('update_icons(): Updating for multiple items selected') |
151 | self.get_toolbar_item('edit_projector', enabled=False) |
152 | self.get_toolbar_item('delete_projector', enabled=False) |
153 | self.get_toolbar_item('view_projector', hidden=True) |
154 | |
155 | === modified file 'openlp/core/projectors/pjlink.py' |
156 | --- openlp/core/projectors/pjlink.py 2019-02-14 15:09:09 +0000 |
157 | +++ openlp/core/projectors/pjlink.py 2019-03-08 15:20:31 +0000 |
158 | @@ -528,8 +528,9 @@ |
159 | sources.append(source) |
160 | sources.sort() |
161 | self.source_available = sources |
162 | - log.debug('({ip}) Setting projector sources_available to "{data}"'.format(ip=self.entry.name, |
163 | - data=self.source_available)) |
164 | + log.debug('({ip}) Setting projector source_available to "{data}"'.format(ip=self.entry.name, |
165 | + data=self.source_available)) |
166 | + self.projectorUpdateIcons.emit() |
167 | return |
168 | |
169 | def process_lamp(self, data): |
170 | @@ -886,6 +887,9 @@ |
171 | elif status >= S_NOT_CONNECTED and status in QSOCKET_STATE: |
172 | # Socket connection status update |
173 | self.status_connect = status |
174 | + # Check if we need to update error state as well |
175 | + if self.error_status != S_OK and status != S_NOT_CONNECTED: |
176 | + self.error_status = S_OK |
177 | elif status >= S_NOT_CONNECTED and status in PROJECTOR_STATE: |
178 | # Only affects the projector status |
179 | self.projector_status = status |
180 | @@ -905,7 +909,14 @@ |
181 | message=status_message if msg is None else msg)) |
182 | |
183 | # Now that we logged extra information for debugging, broadcast the original change/message |
184 | - (code, message) = self._get_status(status) |
185 | + # Check for connection errors first |
186 | + if self.error_status != S_OK: |
187 | + log.debug('({ip}) Signalling error code'.format(ip=self.entry.name)) |
188 | + (code, message) = self._get_status(self.error_status) |
189 | + status = self.error_status |
190 | + else: |
191 | + log.debug('({ip}) Signalling status code'.format(ip=self.entry.name)) |
192 | + (code, message) = self._get_status(status) |
193 | if msg is not None: |
194 | message = msg |
195 | elif message is None: |
196 | @@ -953,7 +964,7 @@ |
197 | log.error('({ip}) Invalid initial packet received - closing socket'.format(ip=self.entry.name)) |
198 | return self.disconnect_from_host() |
199 | # Convert the initial login prompt with the expected PJLink normal command format for processing |
200 | - log.debug('({ip}) check_login(): Formatting initial connection prompt' |
201 | + log.debug('({ip}) check_login(): Formatting initial connection prompt ' |
202 | 'to PJLink packet'.format(ip=self.entry.name)) |
203 | return self.get_data('{start}{clss}{data}'.format(start=PJLINK_PREFIX, |
204 | clss='1', |
205 | |
206 | === modified file 'openlp/core/ui/icons.py' |
207 | --- openlp/core/ui/icons.py 2019-02-15 22:34:53 +0000 |
208 | +++ openlp/core/ui/icons.py 2019-03-08 15:20:31 +0000 |
209 | @@ -117,13 +117,17 @@ |
210 | 'presentation': {'icon': 'fa.bar-chart'}, |
211 | 'preview': {'icon': 'fa.laptop'}, |
212 | 'projector': {'icon': 'op.video'}, |
213 | - 'projector_connect': {'icon': 'fa.plug'}, |
214 | + 'projector_connect': {'icon': 'fa.plug'}, # Projector connect |
215 | 'projector_cooldown': {'icon': 'fa.video-camera', 'attr': 'blue'}, |
216 | - 'projector_disconnect': {'icon': 'fa.plug', 'attr': 'lightGray'}, |
217 | + 'projector_disconnect': {'icon': 'fa.plug', 'attr': 'lightGray'}, # Projector disconnect |
218 | 'projector_error': {'icon': 'fa.video-camera', 'attr': 'red'}, |
219 | 'projector_hdmi': {'icon': 'op.hdmi'}, |
220 | - 'projector_off': {'icon': 'fa.video-camera', 'attr': 'black'}, |
221 | - 'projector_on': {'icon': 'fa.video-camera', 'attr': 'green'}, |
222 | + 'projector_power_off': {'icon': 'fa.video-camera', 'attr': 'red'}, # Toolbar power off |
223 | + 'projector_power_on': {'icon': 'fa.video-camera', 'attr': 'green'}, # Toolbar power on |
224 | + 'projector_off': {'icon': 'fa.video-camera', 'attr': 'black'}, # Projector off |
225 | + 'projector_on': {'icon': 'fa.video-camera', 'attr': 'green'}, # Projector on |
226 | + 'projector_select_connect': {'icon': 'fa.plug', 'attr': 'green'}, # Toolbar connect |
227 | + 'projector_select_disconnect': {'icon': 'fa.plug', 'attr': 'red'}, # Toolbar disconnect |
228 | 'projector_warmup': {'icon': 'fa.video-camera', 'attr': 'yellow'}, |
229 | 'picture': {'icon': 'fa.picture-o'}, |
230 | 'print': {'icon': 'fa.print'}, |
231 | |
232 | === modified file 'setup.cfg' |
233 | --- setup.cfg 2018-10-30 19:46:55 +0000 |
234 | +++ setup.cfg 2019-03-08 15:20:31 +0000 |
235 | @@ -9,6 +9,7 @@ |
236 | |
237 | [flake8] |
238 | exclude=resources.py,vlc.py |
239 | +max-line-length = 120 |
240 | ignore = E402,W503,W504,D |
241 | |
242 | [pycodestyle] |
243 | |
244 | === modified file 'tests/functional/openlp_core/lib/test_image_manager.py' |
245 | --- tests/functional/openlp_core/lib/test_image_manager.py 2019-02-14 15:09:09 +0000 |
246 | +++ tests/functional/openlp_core/lib/test_image_manager.py 2019-03-08 15:20:31 +0000 |
247 | @@ -178,7 +178,7 @@ |
248 | # THEN a KeyError is thrown |
249 | with self.assertRaises(KeyError) as context: |
250 | self.image_manager.get_image(TEST_PATH, 'church1.jpg') |
251 | - assert context.exception is not '', 'KeyError exception should have been thrown for missing image' |
252 | + assert context.exception != '', 'KeyError exception should have been thrown for missing image' |
253 | |
254 | @patch('openlp.core.lib.imagemanager.run_thread') |
255 | def test_different_dimension_image(self, mocked_run_thread): |
256 | @@ -211,7 +211,7 @@ |
257 | # WHEN: calling with correct image, but wrong dimensions |
258 | with self.assertRaises(KeyError) as context: |
259 | self.image_manager.get_image(full_path, 'church.jpg', 120, 120) |
260 | - assert context.exception is not '', 'KeyError exception should have been thrown for missing dimension' |
261 | + assert context.exception != '', 'KeyError exception should have been thrown for missing dimension' |
262 | |
263 | @patch('openlp.core.lib.imagemanager.resize_image') |
264 | @patch('openlp.core.lib.imagemanager.image_to_byte') |
265 | |
266 | === modified file 'tests/functional/openlp_plugins/media/test_mediaplugin.py' |
267 | --- tests/functional/openlp_plugins/media/test_mediaplugin.py 2019-02-14 15:09:09 +0000 |
268 | +++ tests/functional/openlp_plugins/media/test_mediaplugin.py 2019-03-08 15:20:31 +0000 |
269 | @@ -57,4 +57,4 @@ |
270 | # THEN: about() should return a string object |
271 | assert isinstance(MediaPlugin.about(), str) |
272 | # THEN: about() should return a non-empty string |
273 | - assert len(MediaPlugin.about()) is not 0 |
274 | + assert len(MediaPlugin.about()) != 0 |
275 | |
276 | === modified file 'tests/functional/openlp_plugins/songs/test_lib.py' |
277 | --- tests/functional/openlp_plugins/songs/test_lib.py 2019-02-14 15:09:09 +0000 |
278 | +++ tests/functional/openlp_plugins/songs/test_lib.py 2019-03-08 15:20:31 +0000 |
279 | @@ -199,7 +199,7 @@ |
280 | result = _remove_typos(diff) |
281 | |
282 | # THEN: There should be no typos in the middle anymore. The remaining equals should have been merged. |
283 | - assert len(result) is 1, 'The result should contain only one element.' |
284 | + assert len(result) == 1, 'The result should contain only one element.' |
285 | assert result[0][0] == 'equal', 'The result should contain an equal element.' |
286 | assert result[0][1] == 0, 'The start indices should be kept.' |
287 | assert result[0][2] == 22, 'The stop indices should be kept.' |
288 | |
289 | === modified file 'tests/functional/openlp_plugins/songusage/test_songusage.py' |
290 | --- tests/functional/openlp_plugins/songusage/test_songusage.py 2019-02-14 15:09:09 +0000 |
291 | +++ tests/functional/openlp_plugins/songusage/test_songusage.py 2019-03-08 15:20:31 +0000 |
292 | @@ -45,8 +45,8 @@ |
293 | # THEN: about() should return a string object |
294 | assert isinstance(SongUsagePlugin.about(), str) |
295 | # THEN: about() should return a non-empty string |
296 | - assert len(SongUsagePlugin.about()) is not 0 |
297 | - assert len(SongUsagePlugin.about()) is not 0 |
298 | + assert len(SongUsagePlugin.about()) != 0 |
299 | + assert len(SongUsagePlugin.about()) != 0 |
300 | |
301 | @patch('openlp.plugins.songusage.songusageplugin.Manager') |
302 | def test_song_usage_init(self, MockedManager): |
303 | |
304 | === modified file 'tests/openlp_core/projectors/test_projector_db.py' |
305 | --- tests/openlp_core/projectors/test_projector_db.py 2019-02-14 15:09:09 +0000 |
306 | +++ tests/openlp_core/projectors/test_projector_db.py 2019-03-08 15:20:31 +0000 |
307 | @@ -134,6 +134,7 @@ |
308 | """ |
309 | Set up anything necessary for all tests |
310 | """ |
311 | + self.tmp_folder = mkdtemp(prefix='openlp_') |
312 | # Create a test app to keep from segfaulting |
313 | Registry.create() |
314 | self.registry = Registry() |
315 | @@ -153,11 +154,11 @@ |
316 | patch('openlp.core.ui.mainwindow.ThemeManager'), \ |
317 | patch('openlp.core.ui.mainwindow.ProjectorManager'), \ |
318 | patch('openlp.core.ui.mainwindow.websockets.WebSocketServer'), \ |
319 | - patch('openlp.core.ui.mainwindow.server.HttpServer'): |
320 | + patch('openlp.core.ui.mainwindow.server.HttpServer'), \ |
321 | + patch('openlp.core.state.State.list_plugins') as mock_plugins: |
322 | + mock_plugins.return_value = [] |
323 | self.main_window = MainWindow() |
324 | |
325 | - # Create a temporary database directory and database |
326 | - self.tmp_folder = mkdtemp(prefix='openlp_') |
327 | tmpdb_url = 'sqlite:///{db}'.format(db=os.path.join(self.tmp_folder, TEST_DB)) |
328 | mocked_init_url.return_value = tmpdb_url |
329 | self.projector = ProjectorDB() |
330 | |
331 | === modified file 'tests/openlp_core/projectors/test_projector_pjlink_commands_01.py' |
332 | --- tests/openlp_core/projectors/test_projector_pjlink_commands_01.py 2019-02-14 15:09:09 +0000 |
333 | +++ tests/openlp_core/projectors/test_projector_pjlink_commands_01.py 2019-03-08 15:20:31 +0000 |
334 | @@ -452,12 +452,16 @@ |
335 | """ |
336 | Test saving video source available information |
337 | """ |
338 | + |
339 | # GIVEN: Test object |
340 | with patch.object(openlp.core.projectors.pjlink, 'log') as mock_log: |
341 | pjlink = PJLink(Projector(**TEST1_DATA), no_poll=True) |
342 | pjlink.source_available = [] |
343 | - log_debug_calls = [call('({ip}) Setting projector sources_available to ' |
344 | + log_debug_calls = [call('({ip}) reset_information() connect status is ' |
345 | + 'S_NOT_CONNECTED'.format(ip=pjlink.name)), |
346 | + call('({ip}) Setting projector source_available to ' |
347 | '"[\'11\', \'12\', \'21\', \'22\', \'31\', \'32\']"'.format(ip=pjlink.name))] |
348 | + |
349 | chk_data = '21 12 11 22 32 31' # Although they should already be sorted, use unsorted to verify method |
350 | chk_test = ['11', '12', '21', '22', '31', '32'] |
351 |
------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- --- /ci.openlp. io/job/ Branch- 01-Pull/ 2696/ [SUCCESS] /ci.openlp. io/job/ Branch- 02a-Linux- Tests/2590/ [SUCCESS] /ci.openlp. io/job/ Branch- 02b-macOS- Tests/360/ [FAILURE] /ci.openlp. io/job/ Branch- 03a-Build- Source/ 190/ [SUCCESS] /ci.openlp. io/job/ Branch- 03b-Build- macOS/169/ [FAILURE] /ci.openlp. io/job/ Branch- 04a-Code- Lint/1652/ [SUCCESS] /ci.openlp. io/job/ Branch- 04b-Test- Coverage/ 1465/ [SUCCESS] /ci.openlp. io/job/ Branch- 05-AppVeyor- Tests/352/ [FAILURE]
lp:~alisonken1/openlp/pjlink2-u (revision 2849)
https:/
https:/
https:/
https:/
https:/
https:/
https:/
https:/