Merge lp:~alisonken1/openlp/strings-lib into lp:openlp
- strings-lib
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 2664 |
Proposed branch: | lp:~alisonken1/openlp/strings-lib |
Merge into: | lp:openlp |
Diff against target: |
975 lines (+233/-125) 15 files modified
openlp/core/lib/db.py (+22/-18) openlp/core/lib/filedialog.py (+2/-1) openlp/core/lib/htmlbuilder.py (+51/-35) openlp/core/lib/imagemanager.py (+3/-3) openlp/core/lib/mediamanageritem.py (+19/-12) openlp/core/lib/plugin.py (+5/-5) openlp/core/lib/pluginmanager.py (+14/-11) openlp/core/lib/renderer.py (+7/-5) openlp/core/lib/screen.py (+9/-7) openlp/core/lib/searchedit.py (+3/-2) openlp/core/lib/serviceitem.py (+12/-9) openlp/core/lib/theme.py (+2/-1) openlp/core/lib/ui.py (+3/-3) openlp/core/lib/webpagereader.py (+9/-9) tests/functional/openlp_core_lib/test_projector_pjlink1.py (+72/-4) |
To merge this branch: | bzr merge lp:~alisonken1/openlp/strings-lib |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Bentley | Approve | ||
Raoul Snyman | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2016-05-16.
Commit message
openlp/
Description of the change
Convert strings from python2 to python3 format
- Strings converted except as noted
- Updated projector pjlink test
- Simplify lines with multiple references to single variable
-------
lp:~alisonken1/openlp/strings-lib (revision 2665)
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tim Bentley (trb143) : | # |
Preview Diff
1 | === modified file 'openlp/core/lib/db.py' | |||
2 | --- openlp/core/lib/db.py 2016-04-05 17:10:51 +0000 | |||
3 | +++ openlp/core/lib/db.py 2016-05-17 13:27:53 +0000 | |||
4 | @@ -68,9 +68,11 @@ | |||
5 | 68 | :return: The path to the database as type str | 68 | :return: The path to the database as type str |
6 | 69 | """ | 69 | """ |
7 | 70 | if db_file_name is None: | 70 | if db_file_name is None: |
9 | 71 | return 'sqlite:///%s/%s.sqlite' % (AppLocation.get_section_data_path(plugin_name), plugin_name) | 71 | return 'sqlite:///{path}/{plugin}.sqlite'.format(path=AppLocation.get_section_data_path(plugin_name), |
10 | 72 | plugin=plugin_name) | ||
11 | 72 | else: | 73 | else: |
13 | 73 | return 'sqlite:///%s/%s' % (AppLocation.get_section_data_path(plugin_name), db_file_name) | 74 | return 'sqlite:///{path}/{name}'.format(path=AppLocation.get_section_data_path(plugin_name), |
14 | 75 | name=db_file_name) | ||
15 | 74 | 76 | ||
16 | 75 | 77 | ||
17 | 76 | def handle_db_error(plugin_name, db_file_name): | 78 | def handle_db_error(plugin_name, db_file_name): |
18 | @@ -82,10 +84,10 @@ | |||
19 | 82 | :return: None | 84 | :return: None |
20 | 83 | """ | 85 | """ |
21 | 84 | db_path = get_db_path(plugin_name, db_file_name) | 86 | db_path = get_db_path(plugin_name, db_file_name) |
23 | 85 | log.exception('Error loading database: %s', db_path) | 87 | log.exception('Error loading database: {db}'.format(db=db_path)) |
24 | 86 | critical_error_message_box(translate('OpenLP.Manager', 'Database Error'), | 88 | critical_error_message_box(translate('OpenLP.Manager', 'Database Error'), |
27 | 87 | translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') | 89 | translate('OpenLP.Manager', |
28 | 88 | % db_path) | 90 | 'OpenLP cannot load your database.\n\nDatabase: {db}').format(db=db_path)) |
29 | 89 | 91 | ||
30 | 90 | 92 | ||
31 | 91 | def init_url(plugin_name, db_file_name=None): | 93 | def init_url(plugin_name, db_file_name=None): |
32 | @@ -101,10 +103,11 @@ | |||
33 | 101 | if db_type == 'sqlite': | 103 | if db_type == 'sqlite': |
34 | 102 | db_url = get_db_path(plugin_name, db_file_name) | 104 | db_url = get_db_path(plugin_name, db_file_name) |
35 | 103 | else: | 105 | else: |
40 | 104 | db_url = '%s://%s:%s@%s/%s' % (db_type, urlquote(settings.value('db username')), | 106 | db_url = '{type}://{user}:{password}@{host}/{db}'.format(type=db_type, |
41 | 105 | urlquote(settings.value('db password')), | 107 | user=urlquote(settings.value('db username')), |
42 | 106 | urlquote(settings.value('db hostname')), | 108 | password=urlquote(settings.value('db password')), |
43 | 107 | urlquote(settings.value('db database'))) | 109 | host=urlquote(settings.value('db hostname')), |
44 | 110 | db=urlquote(settings.value('db database'))) | ||
45 | 108 | settings.endGroup() | 111 | settings.endGroup() |
46 | 109 | return db_url | 112 | return db_url |
47 | 110 | 113 | ||
48 | @@ -157,10 +160,10 @@ | |||
49 | 157 | return version, upgrade.__version__ | 160 | return version, upgrade.__version__ |
50 | 158 | version += 1 | 161 | version += 1 |
51 | 159 | try: | 162 | try: |
54 | 160 | while hasattr(upgrade, 'upgrade_%d' % version): | 163 | while hasattr(upgrade, 'upgrade_{version:d}'.format(version=version)): |
55 | 161 | log.debug('Running upgrade_%d', version) | 164 | log.debug('Running upgrade_{version:d}'.format(version=version)) |
56 | 162 | try: | 165 | try: |
58 | 163 | upgrade_func = getattr(upgrade, 'upgrade_%d' % version) | 166 | upgrade_func = getattr(upgrade, 'upgrade_{version:d}'.format(version=version)) |
59 | 164 | upgrade_func(session, metadata) | 167 | upgrade_func(session, metadata) |
60 | 165 | session.commit() | 168 | session.commit() |
61 | 166 | # Update the version number AFTER a commit so that we are sure the previous transaction happened | 169 | # Update the version number AFTER a commit so that we are sure the previous transaction happened |
62 | @@ -168,8 +171,8 @@ | |||
63 | 168 | session.commit() | 171 | session.commit() |
64 | 169 | version += 1 | 172 | version += 1 |
65 | 170 | except (SQLAlchemyError, DBAPIError): | 173 | except (SQLAlchemyError, DBAPIError): |
68 | 171 | log.exception('Could not run database upgrade script "upgrade_%s", upgrade process has been halted.', | 174 | log.exception('Could not run database upgrade script ' |
69 | 172 | version) | 175 | '"upgrade_{version:d}", upgrade process has been halted.'.format(version=version)) |
70 | 173 | break | 176 | break |
71 | 174 | except (SQLAlchemyError, DBAPIError): | 177 | except (SQLAlchemyError, DBAPIError): |
72 | 175 | version_meta = Metadata.populate(key='version', value=int(upgrade.__version__)) | 178 | version_meta = Metadata.populate(key='version', value=int(upgrade.__version__)) |
73 | @@ -242,9 +245,10 @@ | |||
74 | 242 | critical_error_message_box( | 245 | critical_error_message_box( |
75 | 243 | translate('OpenLP.Manager', 'Database Error'), | 246 | translate('OpenLP.Manager', 'Database Error'), |
76 | 244 | translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of ' | 247 | translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of ' |
80 | 245 | 'OpenLP. The database is version %d, while OpenLP expects version %d. The database will ' | 248 | 'OpenLP. The database is version {db_ver}, while OpenLP expects version {db_up}. ' |
81 | 246 | 'not be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url) | 249 | 'The database will not be loaded.\n\nDatabase: {db_name}').format(db_ver=db_ver, |
82 | 247 | ) | 250 | db_up=up_ver, |
83 | 251 | db_name=self.db_url)) | ||
84 | 248 | return | 252 | return |
85 | 249 | if not session: | 253 | if not session: |
86 | 250 | try: | 254 | try: |
87 | @@ -460,7 +464,7 @@ | |||
88 | 460 | raise | 464 | raise |
89 | 461 | except InvalidRequestError: | 465 | except InvalidRequestError: |
90 | 462 | self.session.rollback() | 466 | self.session.rollback() |
92 | 463 | log.exception('Failed to delete %s records', object_class.__name__) | 467 | log.exception('Failed to delete {name} records'.format(name=object_class.__name__)) |
93 | 464 | return False | 468 | return False |
94 | 465 | except: | 469 | except: |
95 | 466 | self.session.rollback() | 470 | self.session.rollback() |
96 | 467 | 471 | ||
97 | === modified file 'openlp/core/lib/filedialog.py' | |||
98 | --- openlp/core/lib/filedialog.py 2015-12-31 22:46:06 +0000 | |||
99 | +++ openlp/core/lib/filedialog.py 2016-05-17 13:27:53 +0000 | |||
100 | @@ -50,7 +50,8 @@ | |||
101 | 50 | log.info('File not found. Attempting to unquote.') | 50 | log.info('File not found. Attempting to unquote.') |
102 | 51 | file = parse.unquote(file) | 51 | file = parse.unquote(file) |
103 | 52 | if not os.path.exists(file): | 52 | if not os.path.exists(file): |
105 | 53 | log.error('File %s not found.' % file) | 53 | log.error('File {text} not found.'.format(text=file)) |
106 | 54 | # TODO: Test with UiStrings() before converting to python3 strings | ||
107 | 54 | QtWidgets.QMessageBox.information(parent, UiStrings().FileNotFound, | 55 | QtWidgets.QMessageBox.information(parent, UiStrings().FileNotFound, |
108 | 55 | UiStrings().FileNotFoundMessage % file) | 56 | UiStrings().FileNotFoundMessage % file) |
109 | 56 | continue | 57 | continue |
110 | 57 | 58 | ||
111 | === modified file 'openlp/core/lib/htmlbuilder.py' | |||
112 | --- openlp/core/lib/htmlbuilder.py 2015-12-31 22:46:06 +0000 | |||
113 | +++ openlp/core/lib/htmlbuilder.py 2016-05-17 13:27:53 +0000 | |||
114 | @@ -396,6 +396,7 @@ | |||
115 | 396 | 396 | ||
116 | 397 | log = logging.getLogger(__name__) | 397 | log = logging.getLogger(__name__) |
117 | 398 | 398 | ||
118 | 399 | # TODO: Verify where this is used before converting to python3 | ||
119 | 399 | HTMLSRC = """ | 400 | HTMLSRC = """ |
120 | 400 | <!DOCTYPE html> | 401 | <!DOCTYPE html> |
121 | 401 | <html> | 402 | <html> |
122 | @@ -564,13 +565,13 @@ | |||
123 | 564 | theme_data = item.theme_data | 565 | theme_data = item.theme_data |
124 | 565 | # Image generated and poked in | 566 | # Image generated and poked in |
125 | 566 | if background: | 567 | if background: |
127 | 567 | bgimage_src = 'src="data:image/png;base64,%s"' % background | 568 | bgimage_src = 'src="data:image/png;base64,{image}"'.format(image=background) |
128 | 568 | elif item.bg_image_bytes: | 569 | elif item.bg_image_bytes: |
130 | 569 | bgimage_src = 'src="data:image/png;base64,%s"' % item.bg_image_bytes | 570 | bgimage_src = 'src="data:image/png;base64,{image}"'.format(image=item.bg_image_bytes) |
131 | 570 | else: | 571 | else: |
132 | 571 | bgimage_src = 'style="display:none;"' | 572 | bgimage_src = 'style="display:none;"' |
133 | 572 | if image: | 573 | if image: |
135 | 573 | image_src = 'src="data:image/png;base64,%s"' % image | 574 | image_src = 'src="data:image/png;base64,{image}"'.format(image=image) |
136 | 574 | else: | 575 | else: |
137 | 575 | image_src = 'style="display:none;"' | 576 | image_src = 'style="display:none;"' |
138 | 576 | css_additions = '' | 577 | css_additions = '' |
139 | @@ -601,7 +602,7 @@ | |||
140 | 601 | """ | 602 | """ |
141 | 602 | try: | 603 | try: |
142 | 603 | webkit_ver = float(QtWebKit.qWebKitVersion()) | 604 | webkit_ver = float(QtWebKit.qWebKitVersion()) |
144 | 604 | log.debug('Webkit version = %s' % webkit_ver) | 605 | log.debug('Webkit version = {version}'.format(version=webkit_ver)) |
145 | 605 | except AttributeError: | 606 | except AttributeError: |
146 | 606 | webkit_ver = 0 | 607 | webkit_ver = 0 |
147 | 607 | return webkit_ver | 608 | return webkit_ver |
148 | @@ -621,23 +622,25 @@ | |||
149 | 621 | if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): | 622 | if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): |
150 | 622 | background = '' | 623 | background = '' |
151 | 623 | elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid): | 624 | elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid): |
153 | 624 | background = 'background-color: %s' % theme.background_color | 625 | background = 'background-color: {theme}'.format(theme=theme.background_color) |
154 | 625 | else: | 626 | else: |
155 | 626 | if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): | 627 | if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): |
158 | 627 | background = 'background: -webkit-gradient(linear, left top, left bottom, from(%s), to(%s)) fixed' \ | 628 | background = 'background: -webkit-gradient(linear, left top, left bottom, from({start}), to({end})) ' \ |
159 | 628 | % (theme.background_start_color, theme.background_end_color) | 629 | 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) |
160 | 629 | elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): | 630 | elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): |
163 | 630 | background = 'background: -webkit-gradient(linear, left top, right bottom, from(%s), to(%s)) fixed' \ | 631 | background = 'background: -webkit-gradient(linear, left top, right bottom, from({start}), to({end})) ' \ |
164 | 631 | % (theme.background_start_color, theme.background_end_color) | 632 | 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) |
165 | 632 | elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom): | 633 | elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom): |
168 | 633 | background = 'background: -webkit-gradient(linear, left bottom, right top, from(%s), to(%s)) fixed' \ | 634 | background = 'background: -webkit-gradient(linear, left bottom, right top, from({start}), to({end})) ' \ |
169 | 634 | % (theme.background_start_color, theme.background_end_color) | 635 | 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) |
170 | 635 | elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): | 636 | elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): |
173 | 636 | background = 'background: -webkit-gradient(linear, left top, right top, from(%s), to(%s)) fixed' % \ | 637 | background = 'background: -webkit-gradient(linear, left top, right top, from({start}), to({end})) ' \ |
174 | 637 | (theme.background_start_color, theme.background_end_color) | 638 | 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) |
175 | 638 | else: | 639 | else: |
178 | 639 | background = 'background: -webkit-gradient(radial, %s 50%%, 100, %s 50%%, %s, from(%s), to(%s)) fixed'\ | 640 | background = 'background: -webkit-gradient(radial, {width} 50%, 100, {width} 50%, {width}, ' \ |
179 | 640 | % (width, width, width, theme.background_start_color, theme.background_end_color) | 641 | 'from({start}), to({end})) fixed'.format(width=width, |
180 | 642 | start=theme.background_start_color, | ||
181 | 643 | end=theme.background_end_color) | ||
182 | 641 | return background | 644 | return background |
183 | 642 | 645 | ||
184 | 643 | 646 | ||
185 | @@ -647,6 +650,7 @@ | |||
186 | 647 | 650 | ||
187 | 648 | :param item: Service Item containing theme and location information | 651 | :param item: Service Item containing theme and location information |
188 | 649 | """ | 652 | """ |
189 | 653 | # TODO: Verify this before converting to python3 | ||
190 | 650 | style = """ | 654 | style = """ |
191 | 651 | .lyricstable { | 655 | .lyricstable { |
192 | 652 | z-index: 5; | 656 | z-index: 5; |
193 | @@ -669,12 +673,13 @@ | |||
194 | 669 | lyrics = '' | 673 | lyrics = '' |
195 | 670 | lyricsmain = '' | 674 | lyricsmain = '' |
196 | 671 | if theme_data and item.main: | 675 | if theme_data and item.main: |
198 | 672 | lyricstable = 'left: %spx; top: %spx;' % (item.main.x(), item.main.y()) | 676 | lyricstable = 'left: {left}px; top: {top}px;'.format(left=item.main.x(), top=item.main.y()) |
199 | 673 | lyrics = build_lyrics_format_css(theme_data, item.main.width(), item.main.height()) | 677 | lyrics = build_lyrics_format_css(theme_data, item.main.width(), item.main.height()) |
200 | 674 | lyricsmain += build_lyrics_outline_css(theme_data) | 678 | lyricsmain += build_lyrics_outline_css(theme_data) |
201 | 675 | if theme_data.font_main_shadow: | 679 | if theme_data.font_main_shadow: |
204 | 676 | lyricsmain += ' text-shadow: %s %spx %spx;' % \ | 680 | lyricsmain += ' text-shadow: {theme} {shadow}px ' \ |
205 | 677 | (theme_data.font_main_shadow_color, theme_data.font_main_shadow_size, theme_data.font_main_shadow_size) | 681 | '{shadow}px;'.format(theme=theme_data.font_main_shadow_color, |
206 | 682 | shadow=theme_data.font_main_shadow_size) | ||
207 | 678 | lyrics_css = style % (lyricstable, lyrics, lyricsmain) | 683 | lyrics_css = style % (lyricstable, lyrics, lyricsmain) |
208 | 679 | return lyrics_css | 684 | return lyrics_css |
209 | 680 | 685 | ||
210 | @@ -689,7 +694,9 @@ | |||
211 | 689 | size = float(theme_data.font_main_outline_size) / 16 | 694 | size = float(theme_data.font_main_outline_size) / 16 |
212 | 690 | fill_color = theme_data.font_main_color | 695 | fill_color = theme_data.font_main_color |
213 | 691 | outline_color = theme_data.font_main_outline_color | 696 | outline_color = theme_data.font_main_outline_color |
215 | 692 | return ' -webkit-text-stroke: %sem %s; -webkit-text-fill-color: %s; ' % (size, outline_color, fill_color) | 697 | return ' -webkit-text-stroke: {size}em {color}; -webkit-text-fill-color: {fill}; '.format(size=size, |
216 | 698 | color=outline_color, | ||
217 | 699 | fill=fill_color) | ||
218 | 693 | return '' | 700 | return '' |
219 | 694 | 701 | ||
220 | 695 | 702 | ||
221 | @@ -715,13 +722,21 @@ | |||
222 | 715 | padding_bottom = '0.5em' | 722 | padding_bottom = '0.5em' |
223 | 716 | else: | 723 | else: |
224 | 717 | padding_bottom = '0' | 724 | padding_bottom = '0' |
232 | 718 | lyrics = '%s word-wrap: break-word; ' \ | 725 | lyrics = '{justify} word-wrap: break-word; ' \ |
233 | 719 | 'text-align: %s; vertical-align: %s; font-family: %s; ' \ | 726 | 'text-align: {align}; vertical-align: {valign}; font-family: {font}; ' \ |
234 | 720 | 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \ | 727 | 'font-size: {size}pt; color: {color}; line-height: {line:d}%; margin: 0;' \ |
235 | 721 | 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx; height: %spx; ' % \ | 728 | 'padding: 0; padding-bottom: {bottom}; padding-left: {left}px; width: {width}px; ' \ |
236 | 722 | (justify, align, valign, theme_data.font_main_name, theme_data.font_main_size, | 729 | 'height: {height}px; '.format(justify=justify, |
237 | 723 | theme_data.font_main_color, 100 + int(theme_data.font_main_line_adjustment), padding_bottom, | 730 | align=align, |
238 | 724 | left_margin, width, height) | 731 | valign=valign, |
239 | 732 | font=theme_data.font_main_name, | ||
240 | 733 | size=theme_data.font_main_size, | ||
241 | 734 | color=theme_data.font_main_color, | ||
242 | 735 | line=100 + int(theme_data.font_main_line_adjustment), | ||
243 | 736 | bottom=padding_bottom, | ||
244 | 737 | left=left_margin, | ||
245 | 738 | width=width, | ||
246 | 739 | height=height) | ||
247 | 725 | if theme_data.font_main_italics: | 740 | if theme_data.font_main_italics: |
248 | 726 | lyrics += 'font-style:italic; ' | 741 | lyrics += 'font-style:italic; ' |
249 | 727 | if theme_data.font_main_bold: | 742 | if theme_data.font_main_bold: |
250 | @@ -737,20 +752,21 @@ | |||
251 | 737 | :param height: | 752 | :param height: |
252 | 738 | """ | 753 | """ |
253 | 739 | style = """ | 754 | style = """ |
260 | 740 | left: %spx; | 755 | left: {left}px; |
261 | 741 | bottom: %spx; | 756 | bottom: {bottom}px; |
262 | 742 | width: %spx; | 757 | width: {width}px; |
263 | 743 | font-family: %s; | 758 | font-family: {family}; |
264 | 744 | font-size: %spt; | 759 | font-size: {size}pt; |
265 | 745 | color: %s; | 760 | color: {color}; |
266 | 746 | text-align: left; | 761 | text-align: left; |
268 | 747 | white-space: %s; | 762 | white-space: {space}; |
269 | 748 | """ | 763 | """ |
270 | 749 | theme = item.theme_data | 764 | theme = item.theme_data |
271 | 750 | if not theme or not item.footer: | 765 | if not theme or not item.footer: |
272 | 751 | return '' | 766 | return '' |
273 | 752 | bottom = height - int(item.footer.y()) - int(item.footer.height()) | 767 | bottom = height - int(item.footer.y()) - int(item.footer.height()) |
274 | 753 | whitespace = 'normal' if Settings().value('themes/wrap footer') else 'nowrap' | 768 | whitespace = 'normal' if Settings().value('themes/wrap footer') else 'nowrap' |
277 | 754 | lyrics_html = style % (item.footer.x(), bottom, item.footer.width(), | 769 | lyrics_html = style.format(left=item.footer.x(), bottom=bottom, width=item.footer.width(), |
278 | 755 | theme.font_footer_name, theme.font_footer_size, theme.font_footer_color, whitespace) | 770 | family=theme.font_footer_name, size=theme.font_footer_size, |
279 | 771 | color=theme.font_footer_color, space=whitespace) | ||
280 | 756 | return lyrics_html | 772 | return lyrics_html |
281 | 757 | 773 | ||
282 | === modified file 'openlp/core/lib/imagemanager.py' | |||
283 | --- openlp/core/lib/imagemanager.py 2015-12-31 22:46:06 +0000 | |||
284 | +++ openlp/core/lib/imagemanager.py 2016-05-17 13:27:53 +0000 | |||
285 | @@ -236,7 +236,7 @@ | |||
286 | 236 | """ | 236 | """ |
287 | 237 | Return the ``QImage`` from the cache. If not present wait for the background thread to process it. | 237 | Return the ``QImage`` from the cache. If not present wait for the background thread to process it. |
288 | 238 | """ | 238 | """ |
290 | 239 | log.debug('getImage %s' % path) | 239 | log.debug('getImage {path}'.format(path=path)) |
291 | 240 | image = self._cache[(path, source, width, height)] | 240 | image = self._cache[(path, source, width, height)] |
292 | 241 | if image.image is None: | 241 | if image.image is None: |
293 | 242 | self._conversion_queue.modify_priority(image, Priority.High) | 242 | self._conversion_queue.modify_priority(image, Priority.High) |
294 | @@ -256,7 +256,7 @@ | |||
295 | 256 | """ | 256 | """ |
296 | 257 | Returns the byte string for an image. If not present wait for the background thread to process it. | 257 | Returns the byte string for an image. If not present wait for the background thread to process it. |
297 | 258 | """ | 258 | """ |
299 | 259 | log.debug('get_image_bytes %s' % path) | 259 | log.debug('get_image_bytes {path}'.format(path=path)) |
300 | 260 | image = self._cache[(path, source, width, height)] | 260 | image = self._cache[(path, source, width, height)] |
301 | 261 | if image.image_bytes is None: | 261 | if image.image_bytes is None: |
302 | 262 | self._conversion_queue.modify_priority(image, Priority.Urgent) | 262 | self._conversion_queue.modify_priority(image, Priority.Urgent) |
303 | @@ -271,7 +271,7 @@ | |||
304 | 271 | """ | 271 | """ |
305 | 272 | Add image to cache if it is not already there. | 272 | Add image to cache if it is not already there. |
306 | 273 | """ | 273 | """ |
308 | 274 | log.debug('add_image %s' % path) | 274 | log.debug('add_image {path}'.format(path=path)) |
309 | 275 | if not (path, source, width, height) in self._cache: | 275 | if not (path, source, width, height) in self._cache: |
310 | 276 | image = Image(path, source, background, width, height) | 276 | image = Image(path, source, background, width, height) |
311 | 277 | self._cache[(path, source, width, height)] = image | 277 | self._cache[(path, source, width, height)] = image |
312 | 278 | 278 | ||
313 | === modified file 'openlp/core/lib/mediamanageritem.py' | |||
314 | --- openlp/core/lib/mediamanageritem.py 2016-04-17 19:32:15 +0000 | |||
315 | +++ openlp/core/lib/mediamanageritem.py 2016-05-17 13:27:53 +0000 | |||
316 | @@ -186,7 +186,7 @@ | |||
317 | 186 | for action in toolbar_actions: | 186 | for action in toolbar_actions: |
318 | 187 | if action[0] == StringContent.Preview: | 187 | if action[0] == StringContent.Preview: |
319 | 188 | self.toolbar.addSeparator() | 188 | self.toolbar.addSeparator() |
321 | 189 | self.toolbar.add_toolbar_action('%s%sAction' % (self.plugin.name, action[0]), | 189 | self.toolbar.add_toolbar_action('{name}{action}Action'.format(name=self.plugin.name, action=action[0]), |
322 | 190 | text=self.plugin.get_string(action[1])['title'], icon=action[2], | 190 | text=self.plugin.get_string(action[1])['title'], icon=action[2], |
323 | 191 | tooltip=self.plugin.get_string(action[1])['tooltip'], | 191 | tooltip=self.plugin.get_string(action[1])['tooltip'], |
324 | 192 | triggers=action[3]) | 192 | triggers=action[3]) |
325 | @@ -200,7 +200,7 @@ | |||
326 | 200 | self.list_view.setSpacing(1) | 200 | self.list_view.setSpacing(1) |
327 | 201 | self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) | 201 | self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) |
328 | 202 | self.list_view.setAlternatingRowColors(True) | 202 | self.list_view.setAlternatingRowColors(True) |
330 | 203 | self.list_view.setObjectName('%sListView' % self.plugin.name) | 203 | self.list_view.setObjectName('{name}ListView'.format(name=self.plugin.name)) |
331 | 204 | # Add to page_layout | 204 | # Add to page_layout |
332 | 205 | self.page_layout.addWidget(self.list_view) | 205 | self.page_layout.addWidget(self.list_view) |
333 | 206 | # define and add the context menu | 206 | # define and add the context menu |
334 | @@ -212,19 +212,22 @@ | |||
335 | 212 | triggers=self.on_edit_click) | 212 | triggers=self.on_edit_click) |
336 | 213 | create_widget_action(self.list_view, separator=True) | 213 | create_widget_action(self.list_view, separator=True) |
337 | 214 | create_widget_action(self.list_view, | 214 | create_widget_action(self.list_view, |
339 | 215 | 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()), | 215 | 'listView{plugin}{preview}Item'.format(plugin=self.plugin.name.title(), |
340 | 216 | preview=StringContent.Preview.title()), | ||
341 | 216 | text=self.plugin.get_string(StringContent.Preview)['title'], | 217 | text=self.plugin.get_string(StringContent.Preview)['title'], |
342 | 217 | icon=':/general/general_preview.png', | 218 | icon=':/general/general_preview.png', |
343 | 218 | can_shortcuts=True, | 219 | can_shortcuts=True, |
344 | 219 | triggers=self.on_preview_click) | 220 | triggers=self.on_preview_click) |
345 | 220 | create_widget_action(self.list_view, | 221 | create_widget_action(self.list_view, |
347 | 221 | 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Live.title()), | 222 | 'listView{plugin}{live}Item'.format(plugin=self.plugin.name.title(), |
348 | 223 | live=StringContent.Live.title()), | ||
349 | 222 | text=self.plugin.get_string(StringContent.Live)['title'], | 224 | text=self.plugin.get_string(StringContent.Live)['title'], |
350 | 223 | icon=':/general/general_live.png', | 225 | icon=':/general/general_live.png', |
351 | 224 | can_shortcuts=True, | 226 | can_shortcuts=True, |
352 | 225 | triggers=self.on_live_click) | 227 | triggers=self.on_live_click) |
353 | 226 | create_widget_action(self.list_view, | 228 | create_widget_action(self.list_view, |
355 | 227 | 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Service.title()), | 229 | 'listView{plugin}{service}Item'.format(plugin=self.plugin.name.title(), |
356 | 230 | service=StringContent.Service.title()), | ||
357 | 228 | can_shortcuts=True, | 231 | can_shortcuts=True, |
358 | 229 | text=self.plugin.get_string(StringContent.Service)['title'], | 232 | text=self.plugin.get_string(StringContent.Service)['title'], |
359 | 230 | icon=':/general/general_add.png', | 233 | icon=':/general/general_add.png', |
360 | @@ -232,7 +235,8 @@ | |||
361 | 232 | if self.has_delete_icon: | 235 | if self.has_delete_icon: |
362 | 233 | create_widget_action(self.list_view, separator=True) | 236 | create_widget_action(self.list_view, separator=True) |
363 | 234 | create_widget_action(self.list_view, | 237 | create_widget_action(self.list_view, |
365 | 235 | 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), | 238 | 'listView{plugin}{delete}Item'.format(plugin=self.plugin.name.title(), |
366 | 239 | delete=StringContent.Delete.title()), | ||
367 | 236 | text=self.plugin.get_string(StringContent.Delete)['title'], | 240 | text=self.plugin.get_string(StringContent.Delete)['title'], |
368 | 237 | icon=':/general/general_delete.png', | 241 | icon=':/general/general_delete.png', |
369 | 238 | can_shortcuts=True, triggers=self.on_delete_click) | 242 | can_shortcuts=True, triggers=self.on_delete_click) |
370 | @@ -313,7 +317,7 @@ | |||
371 | 313 | files = FileDialog.getOpenFileNames(self, self.on_new_prompt, | 317 | files = FileDialog.getOpenFileNames(self, self.on_new_prompt, |
372 | 314 | Settings().value(self.settings_section + '/last directory'), | 318 | Settings().value(self.settings_section + '/last directory'), |
373 | 315 | self.on_new_file_masks) | 319 | self.on_new_file_masks) |
375 | 316 | log.info('New files(s) %s' % files) | 320 | log.info('New files(s) {files}'.format(files=files)) |
376 | 317 | if files: | 321 | if files: |
377 | 318 | self.application.set_busy_cursor() | 322 | self.application.set_busy_cursor() |
378 | 319 | self.validate_and_load(files) | 323 | self.validate_and_load(files) |
379 | @@ -333,7 +337,8 @@ | |||
380 | 333 | if not error_shown: | 337 | if not error_shown: |
381 | 334 | critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), | 338 | critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), |
382 | 335 | translate('OpenLP.MediaManagerItem', | 339 | translate('OpenLP.MediaManagerItem', |
384 | 336 | 'Invalid File %s.\nSuffix not supported') % file_name) | 340 | 'Invalid File {name}.\n' |
385 | 341 | 'Suffix not supported').format(name=file_name)) | ||
386 | 337 | error_shown = True | 342 | error_shown = True |
387 | 338 | else: | 343 | else: |
388 | 339 | new_files.append(file_name) | 344 | new_files.append(file_name) |
389 | @@ -375,7 +380,8 @@ | |||
390 | 375 | self.load_list(full_list, target_group) | 380 | self.load_list(full_list, target_group) |
391 | 376 | last_dir = os.path.split(files[0])[0] | 381 | last_dir = os.path.split(files[0])[0] |
392 | 377 | Settings().setValue(self.settings_section + '/last directory', last_dir) | 382 | Settings().setValue(self.settings_section + '/last directory', last_dir) |
394 | 378 | Settings().setValue('%s/%s files' % (self.settings_section, self.settings_section), self.get_file_list()) | 383 | Settings().setValue('{section}/{section} files'.format(section=self.settings_section), |
395 | 384 | self.get_file_list()) | ||
396 | 379 | if duplicates_found: | 385 | if duplicates_found: |
397 | 380 | critical_error_message_box(UiStrings().Duplicate, | 386 | critical_error_message_box(UiStrings().Duplicate, |
398 | 381 | translate('OpenLP.MediaManagerItem', | 387 | translate('OpenLP.MediaManagerItem', |
399 | @@ -550,7 +556,7 @@ | |||
400 | 550 | # Is it possible to process multiple list items to generate | 556 | # Is it possible to process multiple list items to generate |
401 | 551 | # multiple service items? | 557 | # multiple service items? |
402 | 552 | if self.single_service_item: | 558 | if self.single_service_item: |
404 | 553 | log.debug('%s Add requested', self.plugin.name) | 559 | log.debug('{plugin} Add requested'.format(plugin=self.plugin.name)) |
405 | 554 | self.add_to_service(replace=self.remote_triggered) | 560 | self.add_to_service(replace=self.remote_triggered) |
406 | 555 | else: | 561 | else: |
407 | 556 | items = self.list_view.selectedIndexes() | 562 | items = self.list_view.selectedIndexes() |
408 | @@ -591,7 +597,7 @@ | |||
409 | 591 | translate('OpenLP.MediaManagerItem', | 597 | translate('OpenLP.MediaManagerItem', |
410 | 592 | 'You must select one or more items.')) | 598 | 'You must select one or more items.')) |
411 | 593 | else: | 599 | else: |
413 | 594 | log.debug('%s Add requested', self.plugin.name) | 600 | log.debug('{plugin} Add requested'.format(plugin=self.plugin.name)) |
414 | 595 | service_item = self.service_manager.get_service_item() | 601 | service_item = self.service_manager.get_service_item() |
415 | 596 | if not service_item: | 602 | if not service_item: |
416 | 597 | QtWidgets.QMessageBox.information(self, UiStrings().NISs, | 603 | QtWidgets.QMessageBox.information(self, UiStrings().NISs, |
417 | @@ -604,7 +610,8 @@ | |||
418 | 604 | # Turn off the remote edit update message indicator | 610 | # Turn off the remote edit update message indicator |
419 | 605 | QtWidgets.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), | 611 | QtWidgets.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), |
420 | 606 | translate('OpenLP.MediaManagerItem', | 612 | translate('OpenLP.MediaManagerItem', |
422 | 607 | 'You must select a %s service item.') % self.title) | 613 | 'You must select a {title} ' |
423 | 614 | 'service item.').format(title=self.title)) | ||
424 | 608 | 615 | ||
425 | 609 | def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live): | 616 | def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live): |
426 | 610 | """ | 617 | """ |
427 | 611 | 618 | ||
428 | === modified file 'openlp/core/lib/plugin.py' | |||
429 | --- openlp/core/lib/plugin.py 2016-04-04 19:53:54 +0000 | |||
430 | +++ openlp/core/lib/plugin.py 2016-05-17 13:27:53 +0000 | |||
431 | @@ -130,7 +130,7 @@ | |||
432 | 130 | :param settings_tab_class: The class name of the plugin's settings tab. | 130 | :param settings_tab_class: The class name of the plugin's settings tab. |
433 | 131 | :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number. | 131 | :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number. |
434 | 132 | """ | 132 | """ |
436 | 133 | log.debug('Plugin %s initialised' % name) | 133 | log.debug('Plugin {plugin} initialised'.format(plugin=name)) |
437 | 134 | super(Plugin, self).__init__() | 134 | super(Plugin, self).__init__() |
438 | 135 | self.name = name | 135 | self.name = name |
439 | 136 | self.text_strings = {} | 136 | self.text_strings = {} |
440 | @@ -154,11 +154,11 @@ | |||
441 | 154 | # Append a setting for files in the mediamanager (note not all plugins | 154 | # Append a setting for files in the mediamanager (note not all plugins |
442 | 155 | # which have a mediamanager need this). | 155 | # which have a mediamanager need this). |
443 | 156 | if media_item_class is not None: | 156 | if media_item_class is not None: |
445 | 157 | default_settings['%s/%s files' % (name, name)] = [] | 157 | default_settings['{name}/{name} files'.format(name=name)] = [] |
446 | 158 | # Add settings to the dict of all settings. | 158 | # Add settings to the dict of all settings. |
447 | 159 | Settings.extend_default_settings(default_settings) | 159 | Settings.extend_default_settings(default_settings) |
450 | 160 | Registry().register_function('%s_add_service_item' % self.name, self.process_add_service_event) | 160 | Registry().register_function('{name}_add_service_item'.format(name=self.name), self.process_add_service_event) |
451 | 161 | Registry().register_function('%s_config_updated' % self.name, self.config_update) | 161 | Registry().register_function('{name}_config_updated'.format(name=self.name), self.config_update) |
452 | 162 | 162 | ||
453 | 163 | def check_pre_conditions(self): | 163 | def check_pre_conditions(self): |
454 | 164 | """ | 164 | """ |
455 | @@ -256,7 +256,7 @@ | |||
456 | 256 | """ | 256 | """ |
457 | 257 | Generic Drag and drop handler triggered from service_manager. | 257 | Generic Drag and drop handler triggered from service_manager. |
458 | 258 | """ | 258 | """ |
460 | 259 | log.debug('process_add_service_event event called for plugin %s' % self.name) | 259 | log.debug('process_add_service_event event called for plugin {name}'.format(name=self.name)) |
461 | 260 | if replace: | 260 | if replace: |
462 | 261 | self.media_item.on_add_edit_click() | 261 | self.media_item.on_add_edit_click() |
463 | 262 | else: | 262 | else: |
464 | 263 | 263 | ||
465 | === modified file 'openlp/core/lib/pluginmanager.py' | |||
466 | --- openlp/core/lib/pluginmanager.py 2015-12-31 22:46:06 +0000 | |||
467 | +++ openlp/core/lib/pluginmanager.py 2016-05-17 13:27:53 +0000 | |||
468 | @@ -43,7 +43,7 @@ | |||
469 | 43 | super(PluginManager, self).__init__(parent) | 43 | super(PluginManager, self).__init__(parent) |
470 | 44 | self.log_info('Plugin manager Initialising') | 44 | self.log_info('Plugin manager Initialising') |
471 | 45 | self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir)) | 45 | self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir)) |
473 | 46 | self.log_debug('Base path %s ' % self.base_path) | 46 | self.log_debug('Base path {path}'.format(path=self.base_path)) |
474 | 47 | self.plugins = [] | 47 | self.plugins = [] |
475 | 48 | self.log_info('Plugin manager Initialised') | 48 | self.log_info('Plugin manager Initialised') |
476 | 49 | 49 | ||
477 | @@ -73,7 +73,7 @@ | |||
478 | 73 | """ | 73 | """ |
479 | 74 | start_depth = len(os.path.abspath(self.base_path).split(os.sep)) | 74 | start_depth = len(os.path.abspath(self.base_path).split(os.sep)) |
480 | 75 | present_plugin_dir = os.path.join(self.base_path, 'presentations') | 75 | present_plugin_dir = os.path.join(self.base_path, 'presentations') |
482 | 76 | self.log_debug('finding plugins in %s at depth %d' % (self.base_path, start_depth)) | 76 | self.log_debug('finding plugins in {path} at depth {depth:d}'.format(path=self.base_path, depth=start_depth)) |
483 | 77 | for root, dirs, files in os.walk(self.base_path): | 77 | for root, dirs, files in os.walk(self.base_path): |
484 | 78 | for name in files: | 78 | for name in files: |
485 | 79 | if name.endswith('.py') and not name.startswith('__'): | 79 | if name.endswith('.py') and not name.startswith('__'): |
486 | @@ -84,7 +84,9 @@ | |||
487 | 84 | break | 84 | break |
488 | 85 | module_name = name[:-3] | 85 | module_name = name[:-3] |
489 | 86 | # import the modules | 86 | # import the modules |
491 | 87 | self.log_debug('Importing %s from %s. Depth %d' % (module_name, root, this_depth)) | 87 | self.log_debug('Importing {name} from {root}. Depth {depth:d}'.format(name=module_name, |
492 | 88 | root=root, | ||
493 | 89 | depth=this_depth)) | ||
494 | 88 | try: | 90 | try: |
495 | 89 | # Use the "imp" library to try to get around a problem with the PyUNO library which | 91 | # Use the "imp" library to try to get around a problem with the PyUNO library which |
496 | 90 | # monkey-patches the __import__ function to do some magic. This causes issues with our tests. | 92 | # monkey-patches the __import__ function to do some magic. This causes issues with our tests. |
497 | @@ -93,21 +95,21 @@ | |||
498 | 93 | # Then load the module (do the actual import) using the details from find_module() | 95 | # Then load the module (do the actual import) using the details from find_module() |
499 | 94 | imp.load_module(module_name, fp, path_name, description) | 96 | imp.load_module(module_name, fp, path_name, description) |
500 | 95 | except ImportError as e: | 97 | except ImportError as e: |
503 | 96 | self.log_exception('Failed to import module %s on path %s: %s' | 98 | self.log_exception('Failed to import module {name} on path {path}: ' |
504 | 97 | % (module_name, path, e.args[0])) | 99 | '{args}'.format(name=module_name, path=path, args=e.args[0])) |
505 | 98 | plugin_classes = Plugin.__subclasses__() | 100 | plugin_classes = Plugin.__subclasses__() |
506 | 99 | plugin_objects = [] | 101 | plugin_objects = [] |
507 | 100 | for p in plugin_classes: | 102 | for p in plugin_classes: |
508 | 101 | try: | 103 | try: |
509 | 102 | plugin = p() | 104 | plugin = p() |
511 | 103 | self.log_debug('Loaded plugin %s' % str(p)) | 105 | self.log_debug('Loaded plugin {plugin}'.format(plugin=str(p))) |
512 | 104 | plugin_objects.append(plugin) | 106 | plugin_objects.append(plugin) |
513 | 105 | except TypeError: | 107 | except TypeError: |
515 | 106 | self.log_exception('Failed to load plugin %s' % str(p)) | 108 | self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p))) |
516 | 107 | plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) | 109 | plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) |
517 | 108 | for plugin in plugins_list: | 110 | for plugin in plugins_list: |
518 | 109 | if plugin.check_pre_conditions(): | 111 | if plugin.check_pre_conditions(): |
520 | 110 | self.log_debug('Plugin %s active' % str(plugin.name)) | 112 | self.log_debug('Plugin {plugin} active'.format(plugin=str(plugin.name))) |
521 | 111 | plugin.set_status() | 113 | plugin.set_status() |
522 | 112 | else: | 114 | else: |
523 | 113 | plugin.status = PluginStatus.Disabled | 115 | plugin.status = PluginStatus.Disabled |
524 | @@ -175,10 +177,11 @@ | |||
525 | 175 | Loop through all the plugins and give them an opportunity to initialise themselves. | 177 | Loop through all the plugins and give them an opportunity to initialise themselves. |
526 | 176 | """ | 178 | """ |
527 | 177 | for plugin in self.plugins: | 179 | for plugin in self.plugins: |
529 | 178 | self.log_info('initialising plugins %s in a %s state' % (plugin.name, plugin.is_active())) | 180 | self.log_info('initialising plugins {plugin} in a {state} state'.format(plugin=plugin.name, |
530 | 181 | state=plugin.is_active())) | ||
531 | 179 | if plugin.is_active(): | 182 | if plugin.is_active(): |
532 | 180 | plugin.initialise() | 183 | plugin.initialise() |
534 | 181 | self.log_info('Initialisation Complete for %s ' % plugin.name) | 184 | self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name)) |
535 | 182 | 185 | ||
536 | 183 | def finalise_plugins(self): | 186 | def finalise_plugins(self): |
537 | 184 | """ | 187 | """ |
538 | @@ -187,7 +190,7 @@ | |||
539 | 187 | for plugin in self.plugins: | 190 | for plugin in self.plugins: |
540 | 188 | if plugin.is_active(): | 191 | if plugin.is_active(): |
541 | 189 | plugin.finalise() | 192 | plugin.finalise() |
543 | 190 | self.log_info('Finalisation Complete for %s ' % plugin.name) | 193 | self.log_info('Finalisation Complete for {plugin}'.format(plugin=plugin.name)) |
544 | 191 | 194 | ||
545 | 192 | def get_plugin_by_name(self, name): | 195 | def get_plugin_by_name(self, name): |
546 | 193 | """ | 196 | """ |
547 | 194 | 197 | ||
548 | === modified file 'openlp/core/lib/renderer.py' | |||
549 | --- openlp/core/lib/renderer.py 2016-01-23 12:38:08 +0000 | |||
550 | +++ openlp/core/lib/renderer.py 2016-05-17 13:27:53 +0000 | |||
551 | @@ -107,7 +107,7 @@ | |||
552 | 107 | 107 | ||
553 | 108 | :param theme_name: The theme name | 108 | :param theme_name: The theme name |
554 | 109 | """ | 109 | """ |
556 | 110 | self.log_debug("_set_theme with theme %s" % theme_name) | 110 | self.log_debug("_set_theme with theme {theme}".format(theme=theme_name)) |
557 | 111 | if theme_name not in self._theme_dimensions: | 111 | if theme_name not in self._theme_dimensions: |
558 | 112 | theme_data = self.theme_manager.get_theme_data(theme_name) | 112 | theme_data = self.theme_manager.get_theme_data(theme_name) |
559 | 113 | main_rect = self.get_main_rectangle(theme_data) | 113 | main_rect = self.get_main_rectangle(theme_data) |
560 | @@ -183,7 +183,7 @@ | |||
561 | 183 | 183 | ||
562 | 184 | :param item_theme_name: The item theme's name. | 184 | :param item_theme_name: The item theme's name. |
563 | 185 | """ | 185 | """ |
565 | 186 | self.log_debug("set_item_theme with theme %s" % item_theme_name) | 186 | self.log_debug("set_item_theme with theme {theme}".format(theme=item_theme_name)) |
566 | 187 | self._set_theme(item_theme_name) | 187 | self._set_theme(item_theme_name) |
567 | 188 | self.item_theme_name = item_theme_name | 188 | self.item_theme_name = item_theme_name |
568 | 189 | 189 | ||
569 | @@ -317,7 +317,7 @@ | |||
570 | 317 | self.width = screen_size.width() | 317 | self.width = screen_size.width() |
571 | 318 | self.height = screen_size.height() | 318 | self.height = screen_size.height() |
572 | 319 | self.screen_ratio = self.height / self.width | 319 | self.screen_ratio = self.height / self.width |
574 | 320 | self.log_debug('_calculate default %s, %f' % (screen_size, self.screen_ratio)) | 320 | self.log_debug('_calculate default {size}, {ratio:f}'.format(size=screen_size, ratio=self.screen_ratio)) |
575 | 321 | # 90% is start of footer | 321 | # 90% is start of footer |
576 | 322 | self.footer_start = int(self.height * 0.90) | 322 | self.footer_start = int(self.height * 0.90) |
577 | 323 | 323 | ||
578 | @@ -354,7 +354,7 @@ | |||
579 | 354 | :param rect_main: The main text block. | 354 | :param rect_main: The main text block. |
580 | 355 | :param rect_footer: The footer text block. | 355 | :param rect_footer: The footer text block. |
581 | 356 | """ | 356 | """ |
583 | 357 | self.log_debug('_set_text_rectangle %s , %s' % (rect_main, rect_footer)) | 357 | self.log_debug('_set_text_rectangle {main} , {footer}'.format(main=rect_main, footer=rect_footer)) |
584 | 358 | self._rect = rect_main | 358 | self._rect = rect_main |
585 | 359 | self._rect_footer = rect_footer | 359 | self._rect_footer = rect_footer |
586 | 360 | self.page_width = self._rect.width() | 360 | self.page_width = self._rect.width() |
587 | @@ -370,6 +370,7 @@ | |||
588 | 370 | self.web.resize(self.page_width, self.page_height) | 370 | self.web.resize(self.page_width, self.page_height) |
589 | 371 | self.web_frame = self.web.page().mainFrame() | 371 | self.web_frame = self.web.page().mainFrame() |
590 | 372 | # Adjust width and height to account for shadow. outline done in css. | 372 | # Adjust width and height to account for shadow. outline done in css. |
591 | 373 | # TODO: Verify before converting to python3 strings | ||
592 | 373 | html = """<!DOCTYPE html><html><head><script> | 374 | html = """<!DOCTYPE html><html><head><script> |
593 | 374 | function show_text(newtext) { | 375 | function show_text(newtext) { |
594 | 375 | var main = document.getElementById('main'); | 376 | var main = document.getElementById('main'); |
595 | @@ -518,7 +519,8 @@ | |||
596 | 518 | 519 | ||
597 | 519 | :param text: The text to check. It may contain HTML tags. | 520 | :param text: The text to check. It may contain HTML tags. |
598 | 520 | """ | 521 | """ |
600 | 521 | self.web_frame.evaluateJavaScript('show_text("%s")' % text.replace('\\', '\\\\').replace('\"', '\\\"')) | 522 | self.web_frame.evaluateJavaScript('show_text' |
601 | 523 | '("{text}")'.format(text=text.replace('\\', '\\\\').replace('\"', '\\\"'))) | ||
602 | 522 | return self.web_frame.contentsSize().height() <= self.empty_height | 524 | return self.web_frame.contentsSize().height() <= self.empty_height |
603 | 523 | 525 | ||
604 | 524 | 526 | ||
605 | 525 | 527 | ||
606 | === modified file 'openlp/core/lib/screen.py' | |||
607 | --- openlp/core/lib/screen.py 2016-01-10 16:00:05 +0000 | |||
608 | +++ openlp/core/lib/screen.py 2016-05-17 13:27:53 +0000 | |||
609 | @@ -78,7 +78,7 @@ | |||
610 | 78 | ``number`` | 78 | ``number`` |
611 | 79 | The number of the screen, which size has changed. | 79 | The number of the screen, which size has changed. |
612 | 80 | """ | 80 | """ |
614 | 81 | log.info('screen_resolution_changed %d' % number) | 81 | log.info('screen_resolution_changed {number:d}'.format(number=number)) |
615 | 82 | for screen in self.screen_list: | 82 | for screen in self.screen_list: |
616 | 83 | if number == screen['number']: | 83 | if number == screen['number']: |
617 | 84 | new_screen = { | 84 | new_screen = { |
618 | @@ -105,7 +105,7 @@ | |||
619 | 105 | """ | 105 | """ |
620 | 106 | # Do not log at start up. | 106 | # Do not log at start up. |
621 | 107 | if changed_screen != -1: | 107 | if changed_screen != -1: |
623 | 108 | log.info('screen_count_changed %d' % self.desktop.screenCount()) | 108 | log.info('screen_count_changed {count:d}'.format(count=self.desktop.screenCount())) |
624 | 109 | # Remove unplugged screens. | 109 | # Remove unplugged screens. |
625 | 110 | for screen in copy.deepcopy(self.screen_list): | 110 | for screen in copy.deepcopy(self.screen_list): |
626 | 111 | if screen['number'] == self.desktop.screenCount(): | 111 | if screen['number'] == self.desktop.screenCount(): |
627 | @@ -132,9 +132,11 @@ | |||
628 | 132 | """ | 132 | """ |
629 | 133 | screen_list = [] | 133 | screen_list = [] |
630 | 134 | for screen in self.screen_list: | 134 | for screen in self.screen_list: |
632 | 135 | screen_name = '%s %d' % (translate('OpenLP.ScreenList', 'Screen'), screen['number'] + 1) | 135 | screen_name = '{name} {number:d}'.format(name=translate('OpenLP.ScreenList', 'Screen'), |
633 | 136 | number=screen['number'] + 1) | ||
634 | 136 | if screen['primary']: | 137 | if screen['primary']: |
636 | 137 | screen_name = '%s (%s)' % (screen_name, translate('OpenLP.ScreenList', 'primary')) | 138 | screen_name = '{name} ({primary})'.format(name=screen_name, |
637 | 139 | primary=translate('OpenLP.ScreenList', 'primary')) | ||
638 | 138 | screen_list.append(screen_name) | 140 | screen_list.append(screen_name) |
639 | 139 | return screen_list | 141 | return screen_list |
640 | 140 | 142 | ||
641 | @@ -152,7 +154,7 @@ | |||
642 | 152 | 'size': PyQt5.QtCore.QRect(0, 0, 1024, 768) | 154 | 'size': PyQt5.QtCore.QRect(0, 0, 1024, 768) |
643 | 153 | } | 155 | } |
644 | 154 | """ | 156 | """ |
646 | 155 | log.info('Screen %d found with resolution %s' % (screen['number'], screen['size'])) | 157 | log.info('Screen {number:d} found with resolution {size}'.format(number=screen['number'], size=screen['size'])) |
647 | 156 | if screen['primary']: | 158 | if screen['primary']: |
648 | 157 | self.current = screen | 159 | self.current = screen |
649 | 158 | self.override = copy.deepcopy(self.current) | 160 | self.override = copy.deepcopy(self.current) |
650 | @@ -165,7 +167,7 @@ | |||
651 | 165 | 167 | ||
652 | 166 | :param number: The screen number (int). | 168 | :param number: The screen number (int). |
653 | 167 | """ | 169 | """ |
655 | 168 | log.info('remove_screen %d' % number) | 170 | log.info('remove_screen {number:d}'.forma(number=number)) |
656 | 169 | for screen in self.screen_list: | 171 | for screen in self.screen_list: |
657 | 170 | if screen['number'] == number: | 172 | if screen['number'] == number: |
658 | 171 | self.screen_list.remove(screen) | 173 | self.screen_list.remove(screen) |
659 | @@ -189,7 +191,7 @@ | |||
660 | 189 | 191 | ||
661 | 190 | :param number: The screen number (int). | 192 | :param number: The screen number (int). |
662 | 191 | """ | 193 | """ |
664 | 192 | log.debug('set_current_display %s' % number) | 194 | log.debug('set_current_display {number}'.format(number=number)) |
665 | 193 | if number + 1 > self.display_count: | 195 | if number + 1 > self.display_count: |
666 | 194 | self.current = self.screen_list[0] | 196 | self.current = self.screen_list[0] |
667 | 195 | else: | 197 | else: |
668 | 196 | 198 | ||
669 | === modified file 'openlp/core/lib/searchedit.py' | |||
670 | --- openlp/core/lib/searchedit.py 2015-12-31 22:46:06 +0000 | |||
671 | +++ openlp/core/lib/searchedit.py 2016-05-17 13:27:53 +0000 | |||
672 | @@ -62,9 +62,10 @@ | |||
673 | 62 | right_padding = self.clear_button.width() + frame_width | 62 | right_padding = self.clear_button.width() + frame_width |
674 | 63 | if hasattr(self, 'menu_button'): | 63 | if hasattr(self, 'menu_button'): |
675 | 64 | left_padding = self.menu_button.width() | 64 | left_padding = self.menu_button.width() |
677 | 65 | stylesheet = 'QLineEdit { padding-left: %spx; padding-right: %spx; } ' % (left_padding, right_padding) | 65 | stylesheet = 'QLineEdit {{ padding-left:{left}px; padding-right: {right}px; }} '.format(left=left_padding, |
678 | 66 | right=right_padding) | ||
679 | 66 | else: | 67 | else: |
681 | 67 | stylesheet = 'QLineEdit { padding-right: %spx; } ' % right_padding | 68 | stylesheet = 'QLineEdit {{ padding-right: {right}px; }} '.format(right=right_padding) |
682 | 68 | self.setStyleSheet(stylesheet) | 69 | self.setStyleSheet(stylesheet) |
683 | 69 | msz = self.minimumSizeHint() | 70 | msz = self.minimumSizeHint() |
684 | 70 | self.setMinimumSize(max(msz.width(), self.clear_button.width() + (frame_width * 2) + 2), | 71 | self.setMinimumSize(max(msz.width(), self.clear_button.width() + (frame_width * 2) + 2), |
685 | 71 | 72 | ||
686 | === modified file 'openlp/core/lib/serviceitem.py' | |||
687 | --- openlp/core/lib/serviceitem.py 2016-05-05 03:57:04 +0000 | |||
688 | +++ openlp/core/lib/serviceitem.py 2016-05-17 13:27:53 +0000 | |||
689 | @@ -247,7 +247,7 @@ | |||
690 | 247 | self.renderer.set_item_theme(self.theme) | 247 | self.renderer.set_item_theme(self.theme) |
691 | 248 | self.theme_data, self.main, self.footer = self.renderer.pre_render() | 248 | self.theme_data, self.main, self.footer = self.renderer.pre_render() |
692 | 249 | if self.service_item_type == ServiceItemType.Text: | 249 | if self.service_item_type == ServiceItemType.Text: |
694 | 250 | log.debug('Formatting slides: %s' % self.title) | 250 | log.debug('Formatting slides: {title}'.format(title=self.title)) |
695 | 251 | # Save rendered pages to this dict. In the case that a slide is used twice we can use the pages saved to | 251 | # Save rendered pages to this dict. In the case that a slide is used twice we can use the pages saved to |
696 | 252 | # the dict instead of rendering them again. | 252 | # the dict instead of rendering them again. |
697 | 253 | previous_pages = {} | 253 | previous_pages = {} |
698 | @@ -270,7 +270,7 @@ | |||
699 | 270 | elif self.service_item_type == ServiceItemType.Image or self.service_item_type == ServiceItemType.Command: | 270 | elif self.service_item_type == ServiceItemType.Image or self.service_item_type == ServiceItemType.Command: |
700 | 271 | pass | 271 | pass |
701 | 272 | else: | 272 | else: |
703 | 273 | log.error('Invalid value renderer: %s' % self.service_item_type) | 273 | log.error('Invalid value renderer: {item}'.format(item=self.service_item_type)) |
704 | 274 | self.title = clean_tags(self.title) | 274 | self.title = clean_tags(self.title) |
705 | 275 | # The footer should never be None, but to be compatible with a few | 275 | # The footer should never be None, but to be compatible with a few |
706 | 276 | # nightly builds between 1.9.4 and 1.9.5, we have to correct this to | 276 | # nightly builds between 1.9.4 and 1.9.5, we have to correct this to |
707 | @@ -325,7 +325,8 @@ | |||
708 | 325 | self.service_item_type = ServiceItemType.Command | 325 | self.service_item_type = ServiceItemType.Command |
709 | 326 | # If the item should have a display title but this frame doesn't have one, we make one up | 326 | # If the item should have a display title but this frame doesn't have one, we make one up |
710 | 327 | if self.is_capable(ItemCapabilities.HasDisplayTitle) and not display_title: | 327 | if self.is_capable(ItemCapabilities.HasDisplayTitle) and not display_title: |
712 | 328 | display_title = translate('OpenLP.ServiceItem', '[slide %d]') % (len(self._raw_frames) + 1) | 328 | display_title = translate('OpenLP.ServiceItem', |
713 | 329 | '[slide {frame:d}]').format(frame=len(self._raw_frames) + 1) | ||
714 | 329 | # Update image path to match servicemanager location if file was loaded from service | 330 | # Update image path to match servicemanager location if file was loaded from service |
715 | 330 | if image and not self.has_original_files and self.name == 'presentations': | 331 | if image and not self.has_original_files and self.name == 'presentations': |
716 | 331 | file_location = os.path.join(path, file_name) | 332 | file_location = os.path.join(path, file_name) |
717 | @@ -392,7 +393,7 @@ | |||
718 | 392 | :param path: Defaults to *None*. This is the service manager path for things which have their files saved | 393 | :param path: Defaults to *None*. This is the service manager path for things which have their files saved |
719 | 393 | with them or None when the saved service is lite and the original file paths need to be preserved. | 394 | with them or None when the saved service is lite and the original file paths need to be preserved. |
720 | 394 | """ | 395 | """ |
722 | 395 | log.debug('set_from_service called with path %s' % path) | 396 | log.debug('set_from_service called with path {path}'.format(path=path)) |
723 | 396 | header = service_item['serviceitem']['header'] | 397 | header = service_item['serviceitem']['header'] |
724 | 397 | self.title = header['title'] | 398 | self.title = header['title'] |
725 | 398 | self.name = header['name'] | 399 | self.name = header['name'] |
726 | @@ -608,11 +609,13 @@ | |||
727 | 608 | start = None | 609 | start = None |
728 | 609 | end = None | 610 | end = None |
729 | 610 | if self.start_time != 0: | 611 | if self.start_time != 0: |
732 | 611 | start = translate('OpenLP.ServiceItem', '<strong>Start</strong>: %s') % \ | 612 | time = str(datetime.timedelta(seconds=self.start_time)) |
733 | 612 | str(datetime.timedelta(seconds=self.start_time)) | 613 | start = translate('OpenLP.ServiceItem', |
734 | 614 | '<strong>Start</strong>: {start}').format(start=time) | ||
735 | 613 | if self.media_length != 0: | 615 | if self.media_length != 0: |
738 | 614 | end = translate('OpenLP.ServiceItem', '<strong>Length</strong>: %s') % \ | 616 | length = str(datetime.timedelta(seconds=self.media_length // 1000)) |
739 | 615 | str(datetime.timedelta(seconds=self.media_length // 1000)) | 617 | end = translate('OpenLP.ServiceItem', '<strong>Length</strong>: {length}').format(length=length) |
740 | 618 | |||
741 | 616 | if not start and not end: | 619 | if not start and not end: |
742 | 617 | return '' | 620 | return '' |
743 | 618 | elif start and not end: | 621 | elif start and not end: |
744 | @@ -620,7 +623,7 @@ | |||
745 | 620 | elif not start and end: | 623 | elif not start and end: |
746 | 621 | return end | 624 | return end |
747 | 622 | else: | 625 | else: |
749 | 623 | return '%s <br>%s' % (start, end) | 626 | return '{start} <br>{end}'.format(start=start, end=end) |
750 | 624 | 627 | ||
751 | 625 | def update_theme(self, theme): | 628 | def update_theme(self, theme): |
752 | 626 | """ | 629 | """ |
753 | 627 | 630 | ||
754 | === modified file 'openlp/core/lib/theme.py' | |||
755 | --- openlp/core/lib/theme.py 2016-04-30 15:40:23 +0000 | |||
756 | +++ openlp/core/lib/theme.py 2016-05-17 13:27:53 +0000 | |||
757 | @@ -427,7 +427,7 @@ | |||
758 | 427 | try: | 427 | try: |
759 | 428 | theme_xml = objectify.fromstring(xml) | 428 | theme_xml = objectify.fromstring(xml) |
760 | 429 | except etree.XMLSyntaxError: | 429 | except etree.XMLSyntaxError: |
762 | 430 | log.exception('Invalid xml %s', xml) | 430 | log.exception('Invalid xml {text}'.format(text=xml)) |
763 | 431 | return | 431 | return |
764 | 432 | xml_iter = theme_xml.getiterator() | 432 | xml_iter = theme_xml.getiterator() |
765 | 433 | for element in xml_iter: | 433 | for element in xml_iter: |
766 | @@ -513,6 +513,7 @@ | |||
767 | 513 | theme_strings = [] | 513 | theme_strings = [] |
768 | 514 | for key in dir(self): | 514 | for key in dir(self): |
769 | 515 | if key[0:1] != '_': | 515 | if key[0:1] != '_': |
770 | 516 | # TODO: Verify spacing format before converting to python3 string | ||
771 | 516 | theme_strings.append('%30s: %s' % (key, getattr(self, key))) | 517 | theme_strings.append('%30s: %s' % (key, getattr(self, key))) |
772 | 517 | return '\n'.join(theme_strings) | 518 | return '\n'.join(theme_strings) |
773 | 518 | 519 | ||
774 | 519 | 520 | ||
775 | === modified file 'openlp/core/lib/ui.py' | |||
776 | --- openlp/core/lib/ui.py 2016-03-31 16:34:22 +0000 | |||
777 | +++ openlp/core/lib/ui.py 2016-05-17 13:27:53 +0000 | |||
778 | @@ -165,7 +165,7 @@ | |||
779 | 165 | kwargs.setdefault('icon', ':/services/service_down.png') | 165 | kwargs.setdefault('icon', ':/services/service_down.png') |
780 | 166 | kwargs.setdefault('tooltip', translate('OpenLP.Ui', 'Move selection down one position.')) | 166 | kwargs.setdefault('tooltip', translate('OpenLP.Ui', 'Move selection down one position.')) |
781 | 167 | else: | 167 | else: |
783 | 168 | log.warning('The role "%s" is not defined in create_push_button().', role) | 168 | log.warning('The role "{role}" is not defined in create_push_button().'.format(role=role)) |
784 | 169 | if kwargs.pop('btn_class', '') == 'toolbutton': | 169 | if kwargs.pop('btn_class', '') == 'toolbutton': |
785 | 170 | button = QtWidgets.QToolButton(parent) | 170 | button = QtWidgets.QToolButton(parent) |
786 | 171 | else: | 171 | else: |
787 | @@ -183,7 +183,7 @@ | |||
788 | 183 | button.clicked.connect(kwargs.pop('click')) | 183 | button.clicked.connect(kwargs.pop('click')) |
789 | 184 | for key in list(kwargs.keys()): | 184 | for key in list(kwargs.keys()): |
790 | 185 | if key not in ['text', 'icon', 'tooltip', 'click']: | 185 | if key not in ['text', 'icon', 'tooltip', 'click']: |
792 | 186 | log.warning('Parameter %s was not consumed in create_button().', key) | 186 | log.warning('Parameter {key} was not consumed in create_button().'.format(key=key)) |
793 | 187 | return button | 187 | return button |
794 | 188 | 188 | ||
795 | 189 | 189 | ||
796 | @@ -270,7 +270,7 @@ | |||
797 | 270 | action.triggered.connect(kwargs.pop('triggers')) | 270 | action.triggered.connect(kwargs.pop('triggers')) |
798 | 271 | for key in list(kwargs.keys()): | 271 | for key in list(kwargs.keys()): |
799 | 272 | if key not in ['text', 'icon', 'tooltip', 'statustip', 'checked', 'can_shortcuts', 'category', 'triggers']: | 272 | if key not in ['text', 'icon', 'tooltip', 'statustip', 'checked', 'can_shortcuts', 'category', 'triggers']: |
801 | 273 | log.warning('Parameter %s was not consumed in create_action().' % key) | 273 | log.warning('Parameter {key} was not consumed in create_action().'.format(key=key)) |
802 | 274 | return action | 274 | return action |
803 | 275 | 275 | ||
804 | 276 | 276 | ||
805 | 277 | 277 | ||
806 | === modified file 'openlp/core/lib/webpagereader.py' | |||
807 | --- openlp/core/lib/webpagereader.py 2016-04-05 18:33:50 +0000 | |||
808 | +++ openlp/core/lib/webpagereader.py 2016-05-17 13:27:53 +0000 | |||
809 | @@ -133,37 +133,37 @@ | |||
810 | 133 | time.sleep(0.1) | 133 | time.sleep(0.1) |
811 | 134 | try: | 134 | try: |
812 | 135 | page = urllib.request.urlopen(req, timeout=CONNECTION_TIMEOUT) | 135 | page = urllib.request.urlopen(req, timeout=CONNECTION_TIMEOUT) |
814 | 136 | log.debug('Downloaded page {}'.format(page.geturl())) | 136 | log.debug('Downloaded page {text}'.format(text=page.geturl())) |
815 | 137 | break | 137 | break |
816 | 138 | except urllib.error.URLError as err: | 138 | except urllib.error.URLError as err: |
819 | 139 | log.exception('URLError on {}'.format(url)) | 139 | log.exception('URLError on {text}'.format(text=url)) |
820 | 140 | log.exception('URLError: {}'.format(err.reason)) | 140 | log.exception('URLError: {text}'.format(text=err.reason)) |
821 | 141 | page = None | 141 | page = None |
822 | 142 | if retries > CONNECTION_RETRIES: | 142 | if retries > CONNECTION_RETRIES: |
823 | 143 | raise | 143 | raise |
824 | 144 | except socket.timeout: | 144 | except socket.timeout: |
826 | 145 | log.exception('Socket timeout: {}'.format(url)) | 145 | log.exception('Socket timeout: {text}'.format(text=url)) |
827 | 146 | page = None | 146 | page = None |
828 | 147 | if retries > CONNECTION_RETRIES: | 147 | if retries > CONNECTION_RETRIES: |
829 | 148 | raise | 148 | raise |
830 | 149 | except socket.gaierror: | 149 | except socket.gaierror: |
832 | 150 | log.exception('Socket gaierror: {}'.format(url)) | 150 | log.exception('Socket gaierror: {text}'.format(text=url)) |
833 | 151 | page = None | 151 | page = None |
834 | 152 | if retries > CONNECTION_RETRIES: | 152 | if retries > CONNECTION_RETRIES: |
835 | 153 | raise | 153 | raise |
836 | 154 | except ConnectionRefusedError: | 154 | except ConnectionRefusedError: |
838 | 155 | log.exception('ConnectionRefused: {}'.format(url)) | 155 | log.exception('ConnectionRefused: {text}'.format(text=url)) |
839 | 156 | page = None | 156 | page = None |
840 | 157 | if retries > CONNECTION_RETRIES: | 157 | if retries > CONNECTION_RETRIES: |
841 | 158 | raise | 158 | raise |
842 | 159 | break | 159 | break |
843 | 160 | except ConnectionError: | 160 | except ConnectionError: |
845 | 161 | log.exception('Connection error: {}'.format(url)) | 161 | log.exception('Connection error: {text}'.format(text=url)) |
846 | 162 | page = None | 162 | page = None |
847 | 163 | if retries > CONNECTION_RETRIES: | 163 | if retries > CONNECTION_RETRIES: |
848 | 164 | raise | 164 | raise |
849 | 165 | except HTTPException: | 165 | except HTTPException: |
851 | 166 | log.exception('HTTPException error: {}'.format(url)) | 166 | log.exception('HTTPException error: {text}'.format(text=url)) |
852 | 167 | page = None | 167 | page = None |
853 | 168 | if retries > CONNECTION_RETRIES: | 168 | if retries > CONNECTION_RETRIES: |
854 | 169 | raise | 169 | raise |
855 | @@ -173,7 +173,7 @@ | |||
856 | 173 | if update_openlp: | 173 | if update_openlp: |
857 | 174 | Registry().get('application').process_events() | 174 | Registry().get('application').process_events() |
858 | 175 | if not page: | 175 | if not page: |
860 | 176 | log.exception('{} could not be downloaded'.format(url)) | 176 | log.exception('{text} could not be downloaded'.format(text=url)) |
861 | 177 | return None | 177 | return None |
862 | 178 | log.debug(page) | 178 | log.debug(page) |
863 | 179 | return page | 179 | return page |
864 | 180 | 180 | ||
865 | === modified file 'tests/functional/openlp_core_lib/test_projector_pjlink1.py' | |||
866 | --- tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-04-24 11:22:04 +0000 | |||
867 | +++ tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-05-17 13:27:53 +0000 | |||
868 | @@ -112,7 +112,7 @@ | |||
869 | 112 | @patch.object(pjlink_test, 'projectorReceivedData') | 112 | @patch.object(pjlink_test, 'projectorReceivedData') |
870 | 113 | def projector_process_lamp_test(self, mock_projectorReceivedData): | 113 | def projector_process_lamp_test(self, mock_projectorReceivedData): |
871 | 114 | """ | 114 | """ |
873 | 115 | Test setting lamp on/off and hours | 115 | Test status lamp on/off and hours |
874 | 116 | """ | 116 | """ |
875 | 117 | # GIVEN: Test object | 117 | # GIVEN: Test object |
876 | 118 | pjlink = pjlink_test | 118 | pjlink = pjlink_test |
877 | @@ -129,7 +129,7 @@ | |||
878 | 129 | @patch.object(pjlink_test, 'projectorReceivedData') | 129 | @patch.object(pjlink_test, 'projectorReceivedData') |
879 | 130 | def projector_process_multiple_lamp_test(self, mock_projectorReceivedData): | 130 | def projector_process_multiple_lamp_test(self, mock_projectorReceivedData): |
880 | 131 | """ | 131 | """ |
882 | 132 | Test setting multiple lamp on/off and hours | 132 | Test status multiple lamp on/off and hours |
883 | 133 | """ | 133 | """ |
884 | 134 | # GIVEN: Test object | 134 | # GIVEN: Test object |
885 | 135 | pjlink = pjlink_test | 135 | pjlink = pjlink_test |
886 | @@ -156,7 +156,7 @@ | |||
887 | 156 | @patch.object(pjlink_test, 'projectorReceivedData') | 156 | @patch.object(pjlink_test, 'projectorReceivedData') |
888 | 157 | def projector_process_power_on_test(self, mock_projectorReceivedData): | 157 | def projector_process_power_on_test(self, mock_projectorReceivedData): |
889 | 158 | """ | 158 | """ |
891 | 159 | Test setting power to ON | 159 | Test status power to ON |
892 | 160 | """ | 160 | """ |
893 | 161 | # GIVEN: Test object and preset | 161 | # GIVEN: Test object and preset |
894 | 162 | pjlink = pjlink_test | 162 | pjlink = pjlink_test |
895 | @@ -171,7 +171,7 @@ | |||
896 | 171 | @patch.object(pjlink_test, 'projectorReceivedData') | 171 | @patch.object(pjlink_test, 'projectorReceivedData') |
897 | 172 | def projector_process_power_off_test(self, mock_projectorReceivedData): | 172 | def projector_process_power_off_test(self, mock_projectorReceivedData): |
898 | 173 | """ | 173 | """ |
900 | 174 | Test setting power to STANDBY | 174 | Test status power to STANDBY |
901 | 175 | """ | 175 | """ |
902 | 176 | # GIVEN: Test object and preset | 176 | # GIVEN: Test object and preset |
903 | 177 | pjlink = pjlink_test | 177 | pjlink = pjlink_test |
904 | @@ -182,3 +182,71 @@ | |||
905 | 182 | 182 | ||
906 | 183 | # THEN: Power should be set to STANDBY | 183 | # THEN: Power should be set to STANDBY |
907 | 184 | self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY') | 184 | self.assertEquals(pjlink.power, S_STANDBY, 'Power should have been set to STANDBY') |
908 | 185 | |||
909 | 186 | @patch.object(pjlink_test, 'projectorUpdateIcons') | ||
910 | 187 | def projector_process_avmt_closed_unmuted_test(self, mock_projectorReceivedData): | ||
911 | 188 | """ | ||
912 | 189 | Test avmt status shutter closed and audio muted | ||
913 | 190 | """ | ||
914 | 191 | # GIVEN: Test object | ||
915 | 192 | pjlink = pjlink_test | ||
916 | 193 | pjlink.shutter = False | ||
917 | 194 | pjlink.mute = True | ||
918 | 195 | |||
919 | 196 | # WHEN: Called with setting shutter closed and mute off | ||
920 | 197 | pjlink.process_avmt('11') | ||
921 | 198 | |||
922 | 199 | # THEN: Shutter should be True and mute should be False | ||
923 | 200 | self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed') | ||
924 | 201 | self.assertFalse(pjlink.mute, 'Audio should be off') | ||
925 | 202 | |||
926 | 203 | @patch.object(pjlink_test, 'projectorUpdateIcons') | ||
927 | 204 | def projector_process_avmt_open_muted_test(self, mock_projectorReceivedData): | ||
928 | 205 | """ | ||
929 | 206 | Test avmt status shutter open and mute on | ||
930 | 207 | """ | ||
931 | 208 | # GIVEN: Test object | ||
932 | 209 | pjlink = pjlink_test | ||
933 | 210 | pjlink.shutter = True | ||
934 | 211 | pjlink.mute = False | ||
935 | 212 | |||
936 | 213 | # WHEN: Called with setting shutter closed and mute on | ||
937 | 214 | pjlink.process_avmt('21') | ||
938 | 215 | |||
939 | 216 | # THEN: Shutter should be closed and mute should be True | ||
940 | 217 | self.assertFalse(pjlink.shutter, 'Shutter should have been set to closed') | ||
941 | 218 | self.assertTrue(pjlink.mute, 'Audio should be off') | ||
942 | 219 | |||
943 | 220 | @patch.object(pjlink_test, 'projectorUpdateIcons') | ||
944 | 221 | def projector_process_avmt_open_unmuted_test(self, mock_projectorReceivedData): | ||
945 | 222 | """ | ||
946 | 223 | Test avmt status shutter open and mute off off | ||
947 | 224 | """ | ||
948 | 225 | # GIVEN: Test object | ||
949 | 226 | pjlink = pjlink_test | ||
950 | 227 | pjlink.shutter = True | ||
951 | 228 | pjlink.mute = True | ||
952 | 229 | |||
953 | 230 | # WHEN: Called with setting shutter to closed and mute on | ||
954 | 231 | pjlink.process_avmt('30') | ||
955 | 232 | |||
956 | 233 | # THEN: Shutter should be closed and mute should be True | ||
957 | 234 | self.assertFalse(pjlink.shutter, 'Shutter should have been set to open') | ||
958 | 235 | self.assertFalse(pjlink.mute, 'Audio should be on') | ||
959 | 236 | |||
960 | 237 | @patch.object(pjlink_test, 'projectorUpdateIcons') | ||
961 | 238 | def projector_process_avmt_closed_muted_test(self, mock_projectorReceivedData): | ||
962 | 239 | """ | ||
963 | 240 | Test avmt status shutter closed and mute off | ||
964 | 241 | """ | ||
965 | 242 | # GIVEN: Test object | ||
966 | 243 | pjlink = pjlink_test | ||
967 | 244 | pjlink.shutter = False | ||
968 | 245 | pjlink.mute = False | ||
969 | 246 | |||
970 | 247 | # WHEN: Called with setting shutter to closed and mute on | ||
971 | 248 | pjlink.process_avmt('31') | ||
972 | 249 | |||
973 | 250 | # THEN: Shutter should be closed and mute should be True | ||
974 | 251 | self.assertTrue(pjlink.shutter, 'Shutter should have been set to closed') | ||
975 | 252 | self.assertTrue(pjlink.mute, 'Audio should be on') |
Just one question