Merge lp:~alisonken1/openlp/strings-plugins4 into lp:openlp

Proposed by Ken Roberts
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2670
Merged at revision: 2671
Proposed branch: lp:~alisonken1/openlp/strings-plugins4
Merge into: lp:openlp
Diff against target: 184 lines (+89/-16)
3 files modified
openlp/core/lib/projector/pjlink1.py (+3/-1)
openlp/plugins/songusage/forms/songusagedetailform.py (+12/-9)
tests/functional/openlp_core_lib/test_projector_pjlink1.py (+74/-6)
To merge this branch: bzr merge lp:~alisonken1/openlp/strings-plugins4
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tomas Groth Approve
Review via email: mp+295991@code.launchpad.net

Commit message

Convert strings in plugins part 4

Description of the change

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/lib/projector/pjlink1.py'
--- openlp/core/lib/projector/pjlink1.py 2016-04-16 21:32:56 +0000
+++ openlp/core/lib/projector/pjlink1.py 2016-05-28 06:11:20 +0000
@@ -58,7 +58,7 @@
5858
59PJLINK_PREFIX = '%'59PJLINK_PREFIX = '%'
60PJLINK_CLASS = '1'60PJLINK_CLASS = '1'
61PJLINK_HEADER = '%s%s' % (PJLINK_PREFIX, PJLINK_CLASS)61PJLINK_HEADER = '{prefix}{linkclass}'.format(prefix=PJLINK_PREFIX, linkclass=PJLINK_CLASS)
62PJLINK_SUFFIX = CR62PJLINK_SUFFIX = CR
6363
6464
@@ -160,8 +160,10 @@
160 self.source = None160 self.source = None
161 self.other_info = None161 self.other_info = None
162 if hasattr(self, 'timer'):162 if hasattr(self, 'timer'):
163 log.debug('({ip}): Calling timer.stop()'.format(ip=self.ip))
163 self.timer.stop()164 self.timer.stop()
164 if hasattr(self, 'socket_timer'):165 if hasattr(self, 'socket_timer'):
166 log.debug('({ip}): Calling socket_timer.stop()'.format(ip=self.ip))
165 self.socket_timer.stop()167 self.socket_timer.stop()
166 self.send_queue = []168 self.send_queue = []
167 self.send_busy = False169 self.send_busy = False
168170
=== modified file 'openlp/plugins/songusage/forms/songusagedetailform.py'
--- openlp/plugins/songusage/forms/songusagedetailform.py 2016-01-09 16:26:14 +0000
+++ openlp/plugins/songusage/forms/songusagedetailform.py 2016-05-28 06:11:20 +0000
@@ -81,9 +81,10 @@
81 )81 )
82 return82 return
83 check_directory_exists(path)83 check_directory_exists(path)
84 file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % \84 file_name = translate('SongUsagePlugin.SongUsageDetailForm',
85 (self.from_date_calendar.selectedDate().toString('ddMMyyyy'),85 'usage_detail_{old}_{new}.txt'
86 self.to_date_calendar.selectedDate().toString('ddMMyyyy'))86 ).format(old=self.from_date_calendar.selectedDate().toString('ddMMyyyy'),
87 new=self.to_date_calendar.selectedDate().toString('ddMMyyyy'))
87 Settings().setValue(self.plugin.settings_section + '/from date', self.from_date_calendar.selectedDate())88 Settings().setValue(self.plugin.settings_section + '/from date', self.from_date_calendar.selectedDate())
88 Settings().setValue(self.plugin.settings_section + '/to date', self.to_date_calendar.selectedDate())89 Settings().setValue(self.plugin.settings_section + '/to date', self.to_date_calendar.selectedDate())
89 usage = self.plugin.manager.get_all_objects(90 usage = self.plugin.manager.get_all_objects(
@@ -95,21 +96,23 @@
95 try:96 try:
96 file_handle = open(report_file_name, 'wb')97 file_handle = open(report_file_name, 'wb')
97 for instance in usage:98 for instance in usage:
98 record = '\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",' \99 record = ('\"{date}\",\"{time}\",\"{title}\",\"{copyright}\",\"{ccli}\",\"{authors}\",'
99 '\"%s\",\"%s\"\n' % \100 '\"{name}\",\"{source}\"\n').format(date=instance.usagedate, time=instance.usagetime,
100 (instance.usagedate, instance.usagetime, instance.title, instance.copyright,101 title=instance.title, copyright=instance.copyright,
101 instance.ccl_number, instance.authors, instance.plugin_name, instance.source)102 ccli=instance.ccl_number, authors=instance.authors,
103 name=instance.plugin_name, source=instance.source)
102 file_handle.write(record.encode('utf-8'))104 file_handle.write(record.encode('utf-8'))
103 self.main_window.information_message(105 self.main_window.information_message(
104 translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),106 translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),
105 translate('SongUsagePlugin.SongUsageDetailForm',107 translate('SongUsagePlugin.SongUsageDetailForm',
106 'Report \n%s \nhas been successfully created. ') % report_file_name108 'Report \n{name} \nhas been successfully created. ').format(name=report_file_name)
107 )109 )
108 except OSError as ose:110 except OSError as ose:
109 log.exception('Failed to write out song usage records')111 log.exception('Failed to write out song usage records')
110 critical_error_message_box(translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation Failed'),112 critical_error_message_box(translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation Failed'),
111 translate('SongUsagePlugin.SongUsageDetailForm',113 translate('SongUsagePlugin.SongUsageDetailForm',
112 'An error occurred while creating the report: %s') % ose.strerror)114 'An error occurred while creating the report: {error}'
115 ).format(error=ose.strerror))
113 finally:116 finally:
114 if file_handle:117 if file_handle:
115 file_handle.close()118 file_handle.close()
116119
=== modified file 'tests/functional/openlp_core_lib/test_projector_pjlink1.py'
--- tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-05-21 18:19:18 +0000
+++ tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-05-28 06:11:20 +0000
@@ -35,6 +35,20 @@
35pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True)35pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True)
3636
3737
38class DummyTimer(object):
39 '''
40 Dummy class to fake timers
41 '''
42 def __init__(self, *args, **kwargs):
43 pass
44
45 def start(self, *args, **kwargs):
46 pass
47
48 def stop(self, *args, **kwargs):
49 pass
50
51
38class TestPJLink(TestCase):52class TestPJLink(TestCase):
39 """53 """
40 Tests for the PJLink module54 Tests for the PJLink module
@@ -43,13 +57,10 @@
43 @patch.object(pjlink_test, 'send_command')57 @patch.object(pjlink_test, 'send_command')
44 @patch.object(pjlink_test, 'waitForReadyRead')58 @patch.object(pjlink_test, 'waitForReadyRead')
45 @patch('openlp.core.common.qmd5_hash')59 @patch('openlp.core.common.qmd5_hash')
46 def authenticated_connection_call_test(self,60 def authenticated_connection_call_test(self, mock_qmd5_hash, mock_waitForReadyRead, mock_send_command,
47 mock_qmd5_hash,
48 mock_waitForReadyRead,
49 mock_send_command,
50 mock_readyRead):61 mock_readyRead):
51 """62 """
52 Fix for projector connect with PJLink authentication exception. Ticket 92187.63 Ticket 92187: Fix for projector connect with PJLink authentication exception.
53 """64 """
54 # GIVEN: Test object65 # GIVEN: Test object
55 pjlink = pjlink_test66 pjlink = pjlink_test
@@ -63,9 +74,23 @@
63 self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN,74 self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN,
64 "Connection request should have been called with TEST_PIN"))75 "Connection request should have been called with TEST_PIN"))
6576
77 def projector_class_test(self):
78 """
79 Test class version from projector
80 """
81 # GIVEN: Test object
82 pjlink = pjlink_test
83
84 # WHEN: Process class response
85 pjlink.process_clss('1')
86
87 # THEN: Projector class should be set to 1
88 self.assertEquals(pjlink.pjlink_class, '1',
89 'Projector should have returned class=1')
90
66 def non_standard_class_reply_test(self):91 def non_standard_class_reply_test(self):
67 """92 """
68 bugfix 1550891 - CLSS request returns non-standard 'Class N' reply93 Bugfix 1550891: CLSS request returns non-standard 'Class N' reply
69 """94 """
70 # GIVEN: Test object95 # GIVEN: Test object
71 pjlink = pjlink_test96 pjlink = pjlink_test
@@ -264,3 +289,46 @@
264289
265 # THEN: Input selected should reflect current input290 # THEN: Input selected should reflect current input
266 self.assertEquals(pjlink.source, '1', 'Input source should be set to "1"')291 self.assertEquals(pjlink.source, '1', 'Input source should be set to "1"')
292
293 def projector_reset_information_test(self):
294 """
295 Test reset_information() resets all information and stops timers
296 """
297 # GIVEN: Test object and test data
298 pjlink = pjlink_test
299 pjlink.power = S_ON
300 pjlink.pjlink_name = 'OPENLPTEST'
301 pjlink.manufacturer = 'PJLINK'
302 pjlink.model = '1'
303 pjlink.shutter = True
304 pjlink.mute = True
305 pjlink.lamp = True
306 pjlink.fan = True
307 pjlink.source_available = True
308 pjlink.other_info = 'ANOTHER TEST'
309 pjlink.send_queue = True
310 pjlink.send_busy = True
311 pjlink.timer = DummyTimer()
312 pjlink.socket_timer = DummyTimer()
313
314 # WHEN: reset_information() is called
315 with patch.object(pjlink.timer, 'stop') as mock_timer:
316 with patch.object(pjlink.socket_timer, 'stop') as mock_socket_timer:
317 pjlink.reset_information()
318
319 # THEN: All information should be reset and timers stopped
320 self.assertEquals(pjlink.power, S_OFF, 'Projector power should be OFF')
321 self.assertIsNone(pjlink.pjlink_name, 'Projector pjlink_name should be None')
322 self.assertIsNone(pjlink.manufacturer, 'Projector manufacturer should be None')
323 self.assertIsNone(pjlink.model, 'Projector model should be None')
324 self.assertIsNone(pjlink.shutter, 'Projector shutter should be None')
325 self.assertIsNone(pjlink.mute, 'Projector shuttter should be None')
326 self.assertIsNone(pjlink.lamp, 'Projector lamp should be None')
327 self.assertIsNone(pjlink.fan, 'Projector fan should be None')
328 self.assertIsNone(pjlink.source_available, 'Projector source_available should be None')
329 self.assertIsNone(pjlink.source, 'Projector source should be None')
330 self.assertIsNone(pjlink.other_info, 'Projector other_info should be None')
331 self.assertEquals(pjlink.send_queue, [], 'Projector send_queue should be an empty list')
332 self.assertFalse(pjlink.send_busy, 'Projector send_busy should be False')
333 self.assertTrue(mock_timer.called, 'Projector timer.stop() should have been called')
334 self.assertTrue(mock_socket_timer.called, 'Projector socket_timer.stop() should have been called')