Merge lp:~googol-deactivatedaccount/openlp/bug-804747 into lp:openlp
- bug-804747
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Raoul Snyman |
Approved revision: | 1724 |
Merged at revision: | 1714 |
Proposed branch: | lp:~googol-deactivatedaccount/openlp/bug-804747 |
Merge into: | lp:openlp |
Diff against target: |
983 lines (+137/-296) 8 files modified
openlp/core/ui/mainwindow.py (+2/-5) openlp/core/utils/__init__.py (+12/-1) openlp/plugins/bibles/forms/bibleupgradeform.py (+79/-233) openlp/plugins/bibles/forms/languageform.py (+5/-6) openlp/plugins/bibles/lib/db.py (+30/-43) openlp/plugins/bibles/lib/manager.py (+6/-5) openlp/plugins/bibles/lib/mediaitem.py (+1/-1) openlp/plugins/songs/lib/openlyricsexport.py (+2/-2) |
To merge this branch: | bzr merge lp:~googol-deactivatedaccount/openlp/bug-804747 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Tim Bentley | Approve | ||
Review via email: mp+71841@code.launchpad.net |
This proposal supersedes a proposal from 2011-08-15.
Commit message
- Fixed bug #804747 (Bible disappear after upgrade)
- Fixed bug Bug #824129 (Bibles plugin does not always delete corrupted bibles from falied imports)
- Removed not needed or redundant variables.
- Removed not needed code.
- When upgrading bibles move the files to the temp directory.
- clean ups
Description of the change
Hello,
1) Fixed bug #804747 (Bible disappear after upgrade)
The fix is in line 303. We did not pass the file name, that means that we used the version name. If you do not pass the file name the file name is crated from the version name (and since this contained Japanese characters) they were removed (so the file name was ".sqlite")
Furthermore, I changed the way we clean the file name and move the function to utils.
2) Fixed bug Bug #824129 (Bibles plugin does not always delete corrupted bibles from falied imports)
We did not close the session. If you do not close the session, the file cannot be deleted on windows.
3) Removed not needed or redundant variables.
4) Removed not needed code.
I removed the code which allowed you to change the version name in some *rare* (!) circumstances. I do not see why the upgrade wizard should take care of any of this.
5) When upgrading bibles move the files to the temp directory.
6) clean ups
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal | # |
Andreas Preikschat (googol-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
Note: Especially testing on Windows is requested.
Tim Bentley (trb143) : Posted in a previous version of this proposal | # |
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
At a glance looks fine to me.
Andreas Preikschat (googol-deactivatedaccount) wrote : | # |
Fixed a traceback on windows and fixed bug #824129 (there might still be cases where corrupted bibles were not removed, but this fixes this for windows).
Tim Bentley (trb143) : | # |
Raoul Snyman (raoul-snyman) : | # |
Preview Diff
1 | === modified file 'openlp/core/ui/mainwindow.py' |
2 | --- openlp/core/ui/mainwindow.py 2011-08-16 21:19:57 +0000 |
3 | +++ openlp/core/ui/mainwindow.py 2011-08-17 10:17:27 +0000 |
4 | @@ -28,6 +28,7 @@ |
5 | import logging |
6 | import os |
7 | import sys |
8 | +import shutil |
9 | from tempfile import gettempdir |
10 | |
11 | from PyQt4 import QtCore, QtGui |
12 | @@ -726,11 +727,7 @@ |
13 | plugin.firstTime() |
14 | Receiver.send_message(u'openlp_process_events') |
15 | temp_dir = os.path.join(unicode(gettempdir()), u'openlp') |
16 | - if not os.path.exists(temp_dir): |
17 | - return |
18 | - for filename in os.listdir(temp_dir): |
19 | - delete_file(os.path.join(temp_dir, filename)) |
20 | - os.removedirs(temp_dir) |
21 | + shutil.rmtree(temp_dir, True) |
22 | |
23 | def onFirstTimeWizardClicked(self): |
24 | """ |
25 | |
26 | === modified file 'openlp/core/utils/__init__.py' |
27 | --- openlp/core/utils/__init__.py 2011-07-17 15:09:30 +0000 |
28 | +++ openlp/core/utils/__init__.py 2011-08-17 10:17:27 +0000 |
29 | @@ -386,6 +386,17 @@ |
30 | else: |
31 | return os.path.split(path) |
32 | |
33 | +def clean_filename(filename): |
34 | + """ |
35 | + Removes invalid characters from the given ``filename``. |
36 | + |
37 | + ``filename`` |
38 | + The "dirty" file name to clean. |
39 | + """ |
40 | + if not isinstance(filename, unicode): |
41 | + filename = unicode(filename, u'utf-8') |
42 | + return re.sub(r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_') |
43 | + |
44 | def delete_file(file_path_name): |
45 | """ |
46 | Deletes a file from the system. |
47 | @@ -492,4 +503,4 @@ |
48 | __all__ = [u'AppLocation', u'get_application_version', u'check_latest_version', |
49 | u'add_actions', u'get_filesystem_encoding', u'LanguageManager', |
50 | u'ActionList', u'get_web_page', u'file_is_unicode', u'get_uno_command', |
51 | - u'get_uno_instance', u'delete_file'] |
52 | + u'get_uno_instance', u'delete_file', u'clean_filename'] |
53 | |
54 | === modified file 'openlp/plugins/bibles/forms/bibleupgradeform.py' |
55 | --- openlp/plugins/bibles/forms/bibleupgradeform.py 2011-07-14 18:42:38 +0000 |
56 | +++ openlp/plugins/bibles/forms/bibleupgradeform.py 2011-08-17 10:17:27 +0000 |
57 | @@ -29,17 +29,17 @@ |
58 | import logging |
59 | import os |
60 | import shutil |
61 | +from tempfile import gettempdir |
62 | |
63 | from PyQt4 import QtCore, QtGui |
64 | |
65 | from openlp.core.lib import Receiver, SettingsManager, translate, \ |
66 | check_directory_exists |
67 | -from openlp.core.lib.db import delete_database |
68 | from openlp.core.lib.ui import UiStrings, critical_error_message_box |
69 | from openlp.core.ui.wizard import OpenLPWizard, WizardStrings |
70 | from openlp.core.utils import AppLocation, delete_file |
71 | from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB, \ |
72 | - BiblesResourcesDB, clean_filename |
73 | + BiblesResourcesDB |
74 | from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract |
75 | |
76 | log = logging.getLogger(__name__) |
77 | @@ -70,6 +70,7 @@ |
78 | self.suffix = u'.sqlite' |
79 | self.settingsSection = u'bibles' |
80 | self.path = AppLocation.get_section_data_path(self.settingsSection) |
81 | + self.temp_dir = os.path.join(gettempdir(), u'openlp') |
82 | self.files = self.manager.old_bible_databases |
83 | self.success = {} |
84 | self.newbibles = {} |
85 | @@ -91,20 +92,6 @@ |
86 | log.debug(u'Stopping import') |
87 | self.stop_import_flag = True |
88 | |
89 | - def onCheckBoxIndexChanged(self, index): |
90 | - """ |
91 | - Show/Hide warnings if CheckBox state has changed |
92 | - """ |
93 | - for number, filename in enumerate(self.files): |
94 | - if not self.checkBox[number].checkState() == QtCore.Qt.Checked: |
95 | - self.verticalWidget[number].hide() |
96 | - self.formWidget[number].hide() |
97 | - else: |
98 | - version_name = unicode(self.versionNameEdit[number].text()) |
99 | - if self.manager.exists(version_name): |
100 | - self.verticalWidget[number].show() |
101 | - self.formWidget[number].show() |
102 | - |
103 | def reject(self): |
104 | """ |
105 | Stop the wizard on cancel button, close button or ESC key. |
106 | @@ -113,8 +100,6 @@ |
107 | self.stop_import_flag = True |
108 | if not self.currentPage() == self.progressPage: |
109 | self.done(QtGui.QDialog.Rejected) |
110 | - else: |
111 | - self.postWizard() |
112 | |
113 | def onCurrentIdChanged(self, pageId): |
114 | """ |
115 | @@ -124,7 +109,7 @@ |
116 | self.preWizard() |
117 | self.performWizard() |
118 | self.postWizard() |
119 | - elif self.page(pageId) == self.selectPage and self.maxBibles == 0: |
120 | + elif self.page(pageId) == self.selectPage and not self.files: |
121 | self.next() |
122 | |
123 | def onBackupBrowseButtonClicked(self): |
124 | @@ -243,78 +228,13 @@ |
125 | Add the content to the scrollArea. |
126 | """ |
127 | self.checkBox = {} |
128 | - self.versionNameEdit = {} |
129 | - self.versionNameLabel = {} |
130 | - self.versionInfoLabel = {} |
131 | - self.versionInfoPixmap = {} |
132 | - self.verticalWidget = {} |
133 | - self.horizontalLayout = {} |
134 | - self.formWidget = {} |
135 | - self.formLayoutAttention = {} |
136 | for number, filename in enumerate(self.files): |
137 | bible = OldBibleDB(self.mediaItem, path=self.path, file=filename[0]) |
138 | self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) |
139 | - checkBoxName = u'checkBox[%d]' % number |
140 | - self.checkBox[number].setObjectName(checkBoxName) |
141 | + self.checkBox[number].setObjectName(u'checkBox[%d]' % number) |
142 | self.checkBox[number].setText(bible.get_name()) |
143 | self.checkBox[number].setCheckState(QtCore.Qt.Checked) |
144 | self.formLayout.addWidget(self.checkBox[number]) |
145 | - self.verticalWidget[number] = QtGui.QWidget(self.scrollAreaContents) |
146 | - verticalWidgetName = u'verticalWidget[%d]' % number |
147 | - self.verticalWidget[number].setObjectName(verticalWidgetName) |
148 | - self.horizontalLayout[number] = QtGui.QHBoxLayout( |
149 | - self.verticalWidget[number]) |
150 | - self.horizontalLayout[number].setContentsMargins(25, 0, 0, 0) |
151 | - horizontalLayoutName = u'horizontalLayout[%d]' % number |
152 | - self.horizontalLayout[number].setObjectName(horizontalLayoutName) |
153 | - self.versionInfoPixmap[number] = QtGui.QLabel( |
154 | - self.verticalWidget[number]) |
155 | - versionInfoPixmapName = u'versionInfoPixmap[%d]' % number |
156 | - self.versionInfoPixmap[number].setObjectName(versionInfoPixmapName) |
157 | - self.versionInfoPixmap[number].setPixmap(QtGui.QPixmap( |
158 | - u':/bibles/bibles_upgrade_alert.png')) |
159 | - self.versionInfoPixmap[number].setAlignment(QtCore.Qt.AlignRight) |
160 | - self.horizontalLayout[number].addWidget( |
161 | - self.versionInfoPixmap[number]) |
162 | - self.versionInfoLabel[number] = QtGui.QLabel( |
163 | - self.verticalWidget[number]) |
164 | - versionInfoLabelName = u'versionInfoLabel[%d]' % number |
165 | - self.versionInfoLabel[number].setObjectName(versionInfoLabelName) |
166 | - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, |
167 | - QtGui.QSizePolicy.Preferred) |
168 | - sizePolicy.setHorizontalStretch(0) |
169 | - sizePolicy.setVerticalStretch(0) |
170 | - sizePolicy.setHeightForWidth( |
171 | - self.versionInfoLabel[number].sizePolicy().hasHeightForWidth()) |
172 | - self.versionInfoLabel[number].setSizePolicy(sizePolicy) |
173 | - self.horizontalLayout[number].addWidget( |
174 | - self.versionInfoLabel[number]) |
175 | - self.formLayout.addWidget(self.verticalWidget[number]) |
176 | - self.formWidget[number] = QtGui.QWidget(self.scrollAreaContents) |
177 | - formWidgetName = u'formWidget[%d]' % number |
178 | - self.formWidget[number].setObjectName(formWidgetName) |
179 | - self.formLayoutAttention[number] = QtGui.QFormLayout( |
180 | - self.formWidget[number]) |
181 | - self.formLayoutAttention[number].setContentsMargins(25, 0, 0, 5) |
182 | - formLayoutAttentionName = u'formLayoutAttention[%d]' % number |
183 | - self.formLayoutAttention[number].setObjectName( |
184 | - formLayoutAttentionName) |
185 | - self.versionNameLabel[number] = QtGui.QLabel( |
186 | - self.formWidget[number]) |
187 | - self.versionNameLabel[number].setObjectName(u'VersionNameLabel') |
188 | - self.formLayoutAttention[number].setWidget(0, |
189 | - QtGui.QFormLayout.LabelRole, self.versionNameLabel[number]) |
190 | - self.versionNameEdit[number] = QtGui.QLineEdit( |
191 | - self.formWidget[number]) |
192 | - self.versionNameEdit[number].setObjectName(u'VersionNameEdit') |
193 | - self.formLayoutAttention[number].setWidget(0, |
194 | - QtGui.QFormLayout.FieldRole, self.versionNameEdit[number]) |
195 | - self.versionNameEdit[number].setText(bible.get_name()) |
196 | - self.formLayout.addWidget(self.formWidget[number]) |
197 | - # Set up the Signal for the checkbox. |
198 | - QtCore.QObject.connect(self.checkBox[number], |
199 | - QtCore.SIGNAL(u'stateChanged(int)'), |
200 | - self.onCheckBoxIndexChanged) |
201 | self.spacerItem = QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Minimum, |
202 | QtGui.QSizePolicy.Expanding) |
203 | self.formLayout.addItem(self.spacerItem) |
204 | @@ -327,23 +247,6 @@ |
205 | for number, filename in enumerate(self.files): |
206 | self.formLayout.removeWidget(self.checkBox[number]) |
207 | self.checkBox[number].setParent(None) |
208 | - self.horizontalLayout[number].removeWidget( |
209 | - self.versionInfoPixmap[number]) |
210 | - self.versionInfoPixmap[number].setParent(None) |
211 | - self.horizontalLayout[number].removeWidget( |
212 | - self.versionInfoLabel[number]) |
213 | - self.versionInfoLabel[number].setParent(None) |
214 | - self.formLayout.removeWidget(self.verticalWidget[number]) |
215 | - self.verticalWidget[number].setParent(None) |
216 | - self.formLayoutAttention[number].removeWidget( |
217 | - self.versionNameLabel[number]) |
218 | - self.versionNameLabel[number].setParent(None) |
219 | - self.formLayoutAttention[number].removeWidget( |
220 | - self.versionNameEdit[number]) |
221 | - self.formLayoutAttention[number].deleteLater() |
222 | - self.versionNameEdit[number].setParent(None) |
223 | - self.formLayout.removeWidget(self.formWidget[number]) |
224 | - self.formWidget[number].setParent(None) |
225 | self.formLayout.removeItem(self.spacerItem) |
226 | |
227 | def retranslateUi(self): |
228 | @@ -385,12 +288,6 @@ |
229 | self.selectPage.setSubTitle( |
230 | translate('BiblesPlugin.UpgradeWizardForm', |
231 | 'Please select the Bibles to upgrade')) |
232 | - for number, bible in enumerate(self.files): |
233 | - self.versionNameLabel[number].setText( |
234 | - translate('BiblesPlugin.UpgradeWizardForm', 'Version name:')) |
235 | - self.versionInfoLabel[number].setText( |
236 | - translate('BiblesPlugin.UpgradeWizardForm', 'This ' |
237 | - 'Bible still exists. Please change the name or uncheck it.')) |
238 | self.progressPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', |
239 | 'Upgrading')) |
240 | self.progressPage.setSubTitle( |
241 | @@ -425,58 +322,16 @@ |
242 | return False |
243 | return True |
244 | elif self.currentPage() == self.selectPage: |
245 | + check_directory_exists(self.temp_dir) |
246 | for number, filename in enumerate(self.files): |
247 | if not self.checkBox[number].checkState() == QtCore.Qt.Checked: |
248 | continue |
249 | - version_name = unicode(self.versionNameEdit[number].text()) |
250 | - if not version_name: |
251 | - critical_error_message_box(UiStrings().EmptyField, |
252 | - translate('BiblesPlugin.UpgradeWizardForm', |
253 | - 'You need to specify a version name for your Bible.')) |
254 | - self.versionNameEdit[number].setFocus() |
255 | - return False |
256 | - elif self.manager.exists(version_name): |
257 | - critical_error_message_box( |
258 | - translate('BiblesPlugin.UpgradeWizardForm', |
259 | - 'Bible Exists'), |
260 | - translate('BiblesPlugin.UpgradeWizardForm', |
261 | - 'This Bible already exists. Please upgrade ' |
262 | - 'a different Bible, delete the existing one or ' |
263 | - 'uncheck.')) |
264 | - self.versionNameEdit[number].setFocus() |
265 | - return False |
266 | - elif os.path.exists(os.path.join(self.path, clean_filename( |
267 | - version_name))) and version_name == filename[1]: |
268 | - newfilename = u'old_database_%s' % filename[0] |
269 | - if not os.path.exists(os.path.join(self.path, |
270 | - newfilename)): |
271 | - os.rename(os.path.join(self.path, filename[0]), |
272 | - os.path.join(self.path, newfilename)) |
273 | - self.files[number] = [newfilename, filename[1]] |
274 | - continue |
275 | - else: |
276 | - critical_error_message_box( |
277 | - translate('BiblesPlugin.UpgradeWizardForm', |
278 | - 'Bible Exists'), |
279 | - translate('BiblesPlugin.UpgradeWizardForm', |
280 | - 'This Bible already exists. Please upgrade ' |
281 | - 'a different Bible, delete the existing one or ' |
282 | - 'uncheck.')) |
283 | - self.verticalWidget[number].show() |
284 | - self.formWidget[number].show() |
285 | - self.versionNameEdit[number].setFocus() |
286 | - return False |
287 | - elif os.path.exists(os.path.join(self.path, |
288 | - clean_filename(version_name))): |
289 | - critical_error_message_box( |
290 | - translate('BiblesPlugin.UpgradeWizardForm', |
291 | - 'Bible Exists'), |
292 | - translate('BiblesPlugin.UpgradeWizardForm', |
293 | - 'This Bible already exists. Please upgrade ' |
294 | - 'a different Bible, delete the existing one or ' |
295 | - 'uncheck.')) |
296 | - self.versionNameEdit[number].setFocus() |
297 | - return False |
298 | + # Move bibles to temp dir. |
299 | + if not os.path.exists(os.path.join(self.temp_dir, filename[0])): |
300 | + shutil.move( |
301 | + os.path.join(self.path, filename[0]), self.temp_dir) |
302 | + else: |
303 | + delete_file(os.path.join(self.path, filename[0])) |
304 | return True |
305 | if self.currentPage() == self.progressPage: |
306 | return True |
307 | @@ -495,16 +350,8 @@ |
308 | self.files = self.manager.old_bible_databases |
309 | self.addScrollArea() |
310 | self.retranslateUi() |
311 | - self.maxBibles = len(self.files) |
312 | for number, filename in enumerate(self.files): |
313 | self.checkBox[number].setCheckState(QtCore.Qt.Checked) |
314 | - oldname = filename[1] |
315 | - if self.manager.exists(oldname): |
316 | - self.verticalWidget[number].show() |
317 | - self.formWidget[number].show() |
318 | - else: |
319 | - self.verticalWidget[number].hide() |
320 | - self.formWidget[number].hide() |
321 | self.progressBar.show() |
322 | self.restart() |
323 | self.finishButton.setVisible(False) |
324 | @@ -516,9 +363,8 @@ |
325 | Prepare the UI for the upgrade. |
326 | """ |
327 | OpenLPWizard.preWizard(self) |
328 | - self.progressLabel.setText(translate( |
329 | - 'BiblesPlugin.UpgradeWizardForm', |
330 | - 'Starting upgrade...')) |
331 | + self.progressLabel.setText( |
332 | + translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...')) |
333 | Receiver.send_message(u'openlp_process_events') |
334 | |
335 | def performWizard(self): |
336 | @@ -527,48 +373,42 @@ |
337 | """ |
338 | self.include_webbible = False |
339 | proxy_server = None |
340 | - if self.maxBibles == 0: |
341 | + if not self.files: |
342 | self.progressLabel.setText( |
343 | translate('BiblesPlugin.UpgradeWizardForm', 'There are no ' |
344 | 'Bibles that need to be upgraded.')) |
345 | self.progressBar.hide() |
346 | return |
347 | - self.maxBibles = 0 |
348 | + max_bibles = 0 |
349 | for number, file in enumerate(self.files): |
350 | if self.checkBox[number].checkState() == QtCore.Qt.Checked: |
351 | - self.maxBibles += 1 |
352 | - number = 0 |
353 | - for biblenumber, filename in enumerate(self.files): |
354 | + max_bibles += 1 |
355 | + oldBible = None |
356 | + for number, filename in enumerate(self.files): |
357 | + # Close the previous bible's connection. |
358 | + if oldBible is not None: |
359 | + oldBible.close_connection() |
360 | + # Set to None to make obvious that we have already closed the |
361 | + # database. |
362 | + oldBible = None |
363 | if self.stop_import_flag: |
364 | - bible_failed = True |
365 | + self.success[number] = False |
366 | break |
367 | - bible_failed = False |
368 | - self.success[biblenumber] = False |
369 | - if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: |
370 | + if not self.checkBox[number].checkState() == QtCore.Qt.Checked: |
371 | + self.success[number] = False |
372 | continue |
373 | self.progressBar.reset() |
374 | - oldbible = OldBibleDB(self.mediaItem, path=self.path, |
375 | + oldBible = OldBibleDB(self.mediaItem, path=self.temp_dir, |
376 | file=filename[0]) |
377 | name = filename[1] |
378 | - if name is None: |
379 | - delete_file(os.path.join(self.path, filename[0])) |
380 | - self.incrementProgressBar(unicode(translate( |
381 | - 'BiblesPlugin.UpgradeWizardForm', |
382 | - 'Upgrading Bible %s of %s: "%s"\nFailed')) % |
383 | - (number + 1, self.maxBibles, name), |
384 | - self.progressBar.maximum() - self.progressBar.value()) |
385 | - number += 1 |
386 | - continue |
387 | self.progressLabel.setText(unicode(translate( |
388 | 'BiblesPlugin.UpgradeWizardForm', |
389 | 'Upgrading Bible %s of %s: "%s"\nUpgrading ...')) % |
390 | - (number + 1, self.maxBibles, name)) |
391 | - if os.path.exists(os.path.join(self.path, filename[0])): |
392 | - name = unicode(self.versionNameEdit[biblenumber].text()) |
393 | + (number + 1, max_bibles, name)) |
394 | self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, |
395 | - name=name) |
396 | + name=name, file=filename[0]) |
397 | self.newbibles[number].register(self.plugin.upgrade_wizard) |
398 | - metadata = oldbible.get_metadata() |
399 | + metadata = oldBible.get_metadata() |
400 | webbible = False |
401 | meta_data = {} |
402 | for meta in metadata: |
403 | @@ -595,7 +435,7 @@ |
404 | u'name: "%s" failed' % ( |
405 | meta_data[u'download source'], |
406 | meta_data[u'download name'])) |
407 | - delete_database(self.path, clean_filename(name)) |
408 | + self.newbibles[number].session.close() |
409 | del self.newbibles[number] |
410 | critical_error_message_box( |
411 | translate('BiblesPlugin.UpgradeWizardForm', |
412 | @@ -606,9 +446,9 @@ |
413 | self.incrementProgressBar(unicode(translate( |
414 | 'BiblesPlugin.UpgradeWizardForm', |
415 | 'Upgrading Bible %s of %s: "%s"\nFailed')) % |
416 | - (number + 1, self.maxBibles, name), |
417 | + (number + 1, max_bibles, name), |
418 | self.progressBar.maximum() - self.progressBar.value()) |
419 | - number += 1 |
420 | + self.success[number] = False |
421 | continue |
422 | bible = BiblesResourcesDB.get_webbible( |
423 | meta_data[u'download name'], |
424 | @@ -621,25 +461,25 @@ |
425 | language_id = self.newbibles[number].get_language(name) |
426 | if not language_id: |
427 | log.warn(u'Upgrading from "%s" failed' % filename[0]) |
428 | - delete_database(self.path, clean_filename(name)) |
429 | + self.newbibles[number].session.close() |
430 | del self.newbibles[number] |
431 | self.incrementProgressBar(unicode(translate( |
432 | 'BiblesPlugin.UpgradeWizardForm', |
433 | 'Upgrading Bible %s of %s: "%s"\nFailed')) % |
434 | - (number + 1, self.maxBibles, name), |
435 | + (number + 1, max_bibles, name), |
436 | self.progressBar.maximum() - self.progressBar.value()) |
437 | - number += 1 |
438 | + self.success[number] = False |
439 | continue |
440 | self.progressBar.setMaximum(len(books)) |
441 | for book in books: |
442 | if self.stop_import_flag: |
443 | - bible_failed = True |
444 | + self.success[number] = False |
445 | break |
446 | self.incrementProgressBar(unicode(translate( |
447 | 'BiblesPlugin.UpgradeWizardForm', |
448 | 'Upgrading Bible %s of %s: "%s"\n' |
449 | 'Upgrading %s ...')) % |
450 | - (number + 1, self.maxBibles, name, book)) |
451 | + (number + 1, max_bibles, name, book)) |
452 | book_ref_id = self.newbibles[number].\ |
453 | get_book_ref_id_by_name(book, len(books), language_id) |
454 | if not book_ref_id: |
455 | @@ -647,24 +487,24 @@ |
456 | u'name: "%s" aborted by user' % ( |
457 | meta_data[u'download source'], |
458 | meta_data[u'download name'])) |
459 | - delete_database(self.path, clean_filename(name)) |
460 | + self.newbibles[number].session.close() |
461 | del self.newbibles[number] |
462 | - bible_failed = True |
463 | + self.success[number] = False |
464 | break |
465 | book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) |
466 | db_book = self.newbibles[number].create_book(book, |
467 | book_ref_id, book_details[u'testament_id']) |
468 | - # Try to import still downloaded verses |
469 | - oldbook = oldbible.get_book(book) |
470 | + # Try to import already downloaded verses. |
471 | + oldbook = oldBible.get_book(book) |
472 | if oldbook: |
473 | - verses = oldbible.get_verses(oldbook[u'id']) |
474 | + verses = oldBible.get_verses(oldbook[u'id']) |
475 | if not verses: |
476 | log.warn(u'No verses found to import for book ' |
477 | u'"%s"', book) |
478 | continue |
479 | for verse in verses: |
480 | if self.stop_import_flag: |
481 | - bible_failed = True |
482 | + self.success[number] = False |
483 | break |
484 | self.newbibles[number].create_verse(db_book.id, |
485 | int(verse[u'chapter']), |
486 | @@ -678,40 +518,40 @@ |
487 | language_id = self.newbibles[number].get_language(name) |
488 | if not language_id: |
489 | log.warn(u'Upgrading books from "%s" failed' % name) |
490 | - delete_database(self.path, clean_filename(name)) |
491 | + self.newbibles[number].session.close() |
492 | del self.newbibles[number] |
493 | self.incrementProgressBar(unicode(translate( |
494 | 'BiblesPlugin.UpgradeWizardForm', |
495 | 'Upgrading Bible %s of %s: "%s"\nFailed')) % |
496 | - (number + 1, self.maxBibles, name), |
497 | + (number + 1, max_bibles, name), |
498 | self.progressBar.maximum() - self.progressBar.value()) |
499 | - number += 1 |
500 | + self.success[number] = False |
501 | continue |
502 | - books = oldbible.get_books() |
503 | + books = oldBible.get_books() |
504 | self.progressBar.setMaximum(len(books)) |
505 | for book in books: |
506 | if self.stop_import_flag: |
507 | - bible_failed = True |
508 | + self.success[number] = False |
509 | break |
510 | self.incrementProgressBar(unicode(translate( |
511 | 'BiblesPlugin.UpgradeWizardForm', |
512 | 'Upgrading Bible %s of %s: "%s"\n' |
513 | 'Upgrading %s ...')) % |
514 | - (number + 1, self.maxBibles, name, book[u'name'])) |
515 | + (number + 1, max_bibles, name, book[u'name'])) |
516 | book_ref_id = self.newbibles[number].\ |
517 | get_book_ref_id_by_name(book[u'name'], len(books), |
518 | language_id) |
519 | if not book_ref_id: |
520 | log.warn(u'Upgrading books from %s " '\ |
521 | 'failed - aborted by user' % name) |
522 | - delete_database(self.path, clean_filename(name)) |
523 | + self.newbibles[number].session.close() |
524 | del self.newbibles[number] |
525 | - bible_failed = True |
526 | + self.success[number] = False |
527 | break |
528 | book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) |
529 | db_book = self.newbibles[number].create_book(book[u'name'], |
530 | book_ref_id, book_details[u'testament_id']) |
531 | - verses = oldbible.get_verses(book[u'id']) |
532 | + verses = oldBible.get_verses(book[u'id']) |
533 | if not verses: |
534 | log.warn(u'No verses found to import for book ' |
535 | u'"%s"', book[u'name']) |
536 | @@ -719,31 +559,32 @@ |
537 | continue |
538 | for verse in verses: |
539 | if self.stop_import_flag: |
540 | - bible_failed = True |
541 | + self.success[number] = False |
542 | break |
543 | self.newbibles[number].create_verse(db_book.id, |
544 | int(verse[u'chapter']), |
545 | int(verse[u'verse']), unicode(verse[u'text'])) |
546 | Receiver.send_message(u'openlp_process_events') |
547 | self.newbibles[number].session.commit() |
548 | - if not bible_failed: |
549 | + if self.success.has_key(number) and not self.success[number]: |
550 | + self.incrementProgressBar(unicode(translate( |
551 | + 'BiblesPlugin.UpgradeWizardForm', |
552 | + 'Upgrading Bible %s of %s: "%s"\nFailed')) % |
553 | + (number + 1, max_bibles, name), |
554 | + self.progressBar.maximum() - self.progressBar.value()) |
555 | + else: |
556 | + self.success[number] = True |
557 | self.newbibles[number].create_meta(u'Version', name) |
558 | - oldbible.close_connection() |
559 | - delete_file(os.path.join(self.path, filename[0])) |
560 | self.incrementProgressBar(unicode(translate( |
561 | 'BiblesPlugin.UpgradeWizardForm', |
562 | 'Upgrading Bible %s of %s: "%s"\n' |
563 | 'Complete')) % |
564 | - (number + 1, self.maxBibles, name)) |
565 | - self.success[biblenumber] = True |
566 | - else: |
567 | - self.incrementProgressBar(unicode(translate( |
568 | - 'BiblesPlugin.UpgradeWizardForm', |
569 | - 'Upgrading Bible %s of %s: "%s"\nFailed')) % |
570 | - (number + 1, self.maxBibles, name), |
571 | - self.progressBar.maximum() - self.progressBar.value()) |
572 | - delete_database(self.path, clean_filename(name)) |
573 | - number += 1 |
574 | + (number + 1, max_bibles, name)) |
575 | + if self.newbibles.has_key(number): |
576 | + self.newbibles[number].session.close() |
577 | + # Close the last bible's connection if possible. |
578 | + if oldBible is not None: |
579 | + oldBible.close_connection() |
580 | |
581 | def postWizard(self): |
582 | """ |
583 | @@ -752,10 +593,14 @@ |
584 | successful_import = 0 |
585 | failed_import = 0 |
586 | for number, filename in enumerate(self.files): |
587 | - if number in self.success and self.success[number] == True: |
588 | + if self.success.has_key(number) and self.success[number]: |
589 | successful_import += 1 |
590 | elif self.checkBox[number].checkState() == QtCore.Qt.Checked: |
591 | failed_import += 1 |
592 | + # Delete upgraded (but not complete, corrupted, ...) bible. |
593 | + delete_file(os.path.join(self.path, filename[0])) |
594 | + # Copy not upgraded bible back. |
595 | + shutil.move(os.path.join(self.temp_dir, filename[0]), self.path) |
596 | if failed_import > 0: |
597 | failed_import_text = unicode(translate( |
598 | 'BiblesPlugin.UpgradeWizardForm', |
599 | @@ -776,7 +621,8 @@ |
600 | 'Bible(s): %s successful%s')) % (successful_import, |
601 | failed_import_text)) |
602 | else: |
603 | - self.progressLabel.setText( |
604 | - translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade ' |
605 | - 'failed.')) |
606 | + self.progressLabel.setText(translate( |
607 | + 'BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.')) |
608 | + # Remove temp directory. |
609 | + shutil.rmtree(self.temp_dir, True) |
610 | OpenLPWizard.postWizard(self) |
611 | |
612 | === modified file 'openlp/plugins/bibles/forms/languageform.py' |
613 | --- openlp/plugins/bibles/forms/languageform.py 2011-05-26 19:13:11 +0000 |
614 | +++ openlp/plugins/bibles/forms/languageform.py 2011-08-17 10:17:27 +0000 |
615 | @@ -44,8 +44,8 @@ |
616 | Class to manage a dialog which ask the user for a language. |
617 | """ |
618 | log.info(u'LanguageForm loaded') |
619 | - |
620 | - def __init__(self, parent = None): |
621 | + |
622 | + def __init__(self, parent=None): |
623 | """ |
624 | Constructor |
625 | """ |
626 | @@ -57,12 +57,11 @@ |
627 | if bible_name: |
628 | self.bibleLabel.setText(unicode(bible_name)) |
629 | items = BiblesResourcesDB.get_languages() |
630 | - for item in items: |
631 | - self.languageComboBox.addItem(item[u'name']) |
632 | + self.languageComboBox.addItems([item[u'name'] for item in items]) |
633 | return QDialog.exec_(self) |
634 | - |
635 | + |
636 | def accept(self): |
637 | - if self.languageComboBox.currentText() == u'': |
638 | + if not self.languageComboBox.currentText(): |
639 | critical_error_message_box( |
640 | message=translate('BiblesPlugin.LanguageForm', |
641 | 'You need to choose a language.')) |
642 | |
643 | === modified file 'openlp/plugins/bibles/lib/db.py' |
644 | --- openlp/plugins/bibles/lib/db.py 2011-07-07 18:03:12 +0000 |
645 | +++ openlp/plugins/bibles/lib/db.py 2011-08-17 10:17:27 +0000 |
646 | @@ -39,7 +39,7 @@ |
647 | from openlp.core.lib import Receiver, translate |
648 | from openlp.core.lib.db import BaseModel, init_db, Manager |
649 | from openlp.core.lib.ui import critical_error_message_box |
650 | -from openlp.core.utils import AppLocation |
651 | +from openlp.core.utils import AppLocation, clean_filename |
652 | |
653 | log = logging.getLogger(__name__) |
654 | |
655 | @@ -63,19 +63,6 @@ |
656 | """ |
657 | pass |
658 | |
659 | -def clean_filename(filename): |
660 | - """ |
661 | - Clean up the version name of the Bible and convert it into a valid |
662 | - file name. |
663 | - |
664 | - ``filename`` |
665 | - The "dirty" file name or version name. |
666 | - """ |
667 | - if not isinstance(filename, unicode): |
668 | - filename = unicode(filename, u'utf-8') |
669 | - filename = re.sub(r'[^\w]+', u'_', filename).strip(u'_') |
670 | - return filename + u'.sqlite' |
671 | - |
672 | def init_schema(url): |
673 | """ |
674 | Setup a bible database connection and initialise the database schema. |
675 | @@ -158,7 +145,7 @@ |
676 | self.name = kwargs[u'name'] |
677 | if not isinstance(self.name, unicode): |
678 | self.name = unicode(self.name, u'utf-8') |
679 | - self.file = clean_filename(self.name) |
680 | + self.file = clean_filename(self.name) + u'.sqlite' |
681 | if u'file' in kwargs: |
682 | self.file = kwargs[u'file'] |
683 | Manager.__init__(self, u'bibles', init_schema, self.file) |
684 | @@ -210,7 +197,7 @@ |
685 | The book_reference_id from bibles_resources.sqlite of the book. |
686 | |
687 | ``testament`` |
688 | - *Defaults to 1.* The testament_reference_id from |
689 | + *Defaults to 1.* The testament_reference_id from |
690 | bibles_resources.sqlite of the testament this book belongs to. |
691 | """ |
692 | log.debug(u'BibleDB.create_book("%s", "%s")', name, bk_ref_id) |
693 | @@ -329,7 +316,7 @@ |
694 | return self.get_object_filtered(Book, Book.book_reference_id.like(id)) |
695 | |
696 | def get_book_ref_id_by_name(self, book, maxbooks, language_id=None): |
697 | - log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, |
698 | + log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, |
699 | language_id) |
700 | if BiblesResourcesDB.get_book(book, True): |
701 | book_temp = BiblesResourcesDB.get_book(book, True) |
702 | @@ -471,7 +458,7 @@ |
703 | |
704 | def get_language(self, bible_name=None): |
705 | """ |
706 | - If no language is given it calls a dialog window where the user could |
707 | + If no language is given it calls a dialog window where the user could |
708 | select the bible language. |
709 | Return the language id of a bible. |
710 | |
711 | @@ -521,9 +508,9 @@ |
712 | some resources which are used in the Bibles plugin. |
713 | A wrapper class around a small SQLite database which contains the download |
714 | resources, a biblelist from the different download resources, the books, |
715 | - chapter counts and verse counts for the web download Bibles, a language |
716 | - reference, the testament reference and some alternative book names. This |
717 | - class contains a singleton "cursor" so that only one connection to the |
718 | + chapter counts and verse counts for the web download Bibles, a language |
719 | + reference, the testament reference and some alternative book names. This |
720 | + class contains a singleton "cursor" so that only one connection to the |
721 | SQLite database is ever used. |
722 | """ |
723 | cursor = None |
724 | @@ -582,7 +569,7 @@ |
725 | |
726 | ``name`` |
727 | The name or abbreviation of the book. |
728 | - |
729 | + |
730 | ``lower`` |
731 | True if the comparsion should be only lowercase |
732 | """ |
733 | @@ -592,7 +579,7 @@ |
734 | if lower: |
735 | books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' |
736 | u'abbreviation, chapters FROM book_reference WHERE ' |
737 | - u'LOWER(name) = ? OR LOWER(abbreviation) = ?', |
738 | + u'LOWER(name) = ? OR LOWER(abbreviation) = ?', |
739 | (name.lower(), name.lower())) |
740 | else: |
741 | books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' |
742 | @@ -621,7 +608,7 @@ |
743 | if not isinstance(id, int): |
744 | id = int(id) |
745 | books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' |
746 | - u'abbreviation, chapters FROM book_reference WHERE id = ?', |
747 | + u'abbreviation, chapters FROM book_reference WHERE id = ?', |
748 | (id, )) |
749 | if books: |
750 | return { |
751 | @@ -645,12 +632,12 @@ |
752 | ``chapter`` |
753 | The chapter number. |
754 | """ |
755 | - log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, |
756 | + log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, |
757 | chapter) |
758 | if not isinstance(chapter, int): |
759 | chapter = int(chapter) |
760 | chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' |
761 | - u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', |
762 | + u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', |
763 | (book_id,)) |
764 | if chapters: |
765 | return { |
766 | @@ -687,7 +674,7 @@ |
767 | ``chapter`` |
768 | The number of the chapter. |
769 | """ |
770 | - log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id, |
771 | + log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id, |
772 | chapter) |
773 | details = BiblesResourcesDB.get_chapter(book_id, chapter) |
774 | if details: |
775 | @@ -715,7 +702,7 @@ |
776 | } |
777 | else: |
778 | return None |
779 | - |
780 | + |
781 | @staticmethod |
782 | def get_webbibles(source): |
783 | """ |
784 | @@ -737,7 +724,7 @@ |
785 | u'id': bible[0], |
786 | u'name': bible[1], |
787 | u'abbreviation': bible[2], |
788 | - u'language_id': bible[3], |
789 | + u'language_id': bible[3], |
790 | u'download_source_id': bible[4] |
791 | } |
792 | for bible in bibles |
793 | @@ -752,11 +739,11 @@ |
794 | |
795 | ``abbreviation`` |
796 | The abbreviation of the webbible. |
797 | - |
798 | + |
799 | ``source`` |
800 | The source of the webbible. |
801 | """ |
802 | - log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, |
803 | + log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, |
804 | source) |
805 | if not isinstance(abbreviation, unicode): |
806 | abbreviation = unicode(abbreviation) |
807 | @@ -765,14 +752,14 @@ |
808 | source = BiblesResourcesDB.get_download_source(source) |
809 | bible = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, ' |
810 | u'language_id, download_source_id FROM webbibles WHERE ' |
811 | - u'download_source_id = ? AND abbreviation = ?', (source[u'id'], |
812 | + u'download_source_id = ? AND abbreviation = ?', (source[u'id'], |
813 | abbreviation)) |
814 | if bible: |
815 | return { |
816 | u'id': bible[0][0], |
817 | u'name': bible[0][1], |
818 | u'abbreviation': bible[0][2], |
819 | - u'language_id': bible[0][3], |
820 | + u'language_id': bible[0][3], |
821 | u'download_source_id': bible[0][4] |
822 | } |
823 | else: |
824 | @@ -785,11 +772,11 @@ |
825 | |
826 | ``name`` |
827 | The name to search the id. |
828 | - |
829 | + |
830 | ``language_id`` |
831 | The language_id for which language should be searched |
832 | """ |
833 | - log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")', |
834 | + log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")', |
835 | name, language_id) |
836 | if language_id: |
837 | books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name ' |
838 | @@ -806,7 +793,7 @@ |
839 | @staticmethod |
840 | def get_language(name): |
841 | """ |
842 | - Return a dict containing the language id, name and code by name or |
843 | + Return a dict containing the language id, name and code by name or |
844 | abbreviation. |
845 | |
846 | ``name`` |
847 | @@ -865,7 +852,7 @@ |
848 | |
849 | class AlternativeBookNamesDB(QtCore.QObject, Manager): |
850 | """ |
851 | - This class represents a database-bound alternative book names system. |
852 | + This class represents a database-bound alternative book names system. |
853 | """ |
854 | cursor = None |
855 | conn = None |
856 | @@ -874,7 +861,7 @@ |
857 | def get_cursor(): |
858 | """ |
859 | Return the cursor object. Instantiate one if it doesn't exist yet. |
860 | - If necessary loads up the database and creates the tables if the |
861 | + If necessary loads up the database and creates the tables if the |
862 | database doesn't exist. |
863 | """ |
864 | if AlternativeBookNamesDB.cursor is None: |
865 | @@ -904,7 +891,7 @@ |
866 | |
867 | ``parameters`` |
868 | Any variable parameters to add to the query |
869 | - |
870 | + |
871 | ``commit`` |
872 | If a commit statement is necessary this should be True. |
873 | """ |
874 | @@ -921,11 +908,11 @@ |
875 | |
876 | ``name`` |
877 | The name to search the id. |
878 | - |
879 | + |
880 | ``language_id`` |
881 | The language_id for which language should be searched |
882 | """ |
883 | - log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', |
884 | + log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', |
885 | name, language_id) |
886 | if language_id: |
887 | books = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id, ' |
888 | @@ -962,11 +949,11 @@ |
889 | |
890 | class OldBibleDB(QtCore.QObject, Manager): |
891 | """ |
892 | - This class conects to the old bible databases to reimport them to the new |
893 | + This class conects to the old bible databases to reimport them to the new |
894 | database scheme. |
895 | """ |
896 | cursor = None |
897 | - |
898 | + |
899 | def __init__(self, parent, **kwargs): |
900 | """ |
901 | The constructor loads up the database and creates and initialises the |
902 | |
903 | === modified file 'openlp/plugins/bibles/lib/manager.py' |
904 | --- openlp/plugins/bibles/lib/manager.py 2011-07-07 18:03:12 +0000 |
905 | +++ openlp/plugins/bibles/lib/manager.py 2011-08-17 10:17:27 +0000 |
906 | @@ -151,9 +151,10 @@ |
907 | name = bible.get_name() |
908 | # Remove corrupted files. |
909 | if name is None: |
910 | + bible.session.close() |
911 | delete_file(os.path.join(self.path, filename)) |
912 | continue |
913 | - # Find old database versions |
914 | + # Find old database versions. |
915 | if bible.is_old_database(): |
916 | self.old_bible_databases.append([filename, name]) |
917 | bible.session.close() |
918 | @@ -220,7 +221,7 @@ |
919 | return [ |
920 | { |
921 | u'name': book.name, |
922 | - u'book_reference_id': book.book_reference_id, |
923 | + u'book_reference_id': book.book_reference_id, |
924 | u'chapters': self.db_cache[bible].get_chapter_count(book) |
925 | } |
926 | for book in self.db_cache[bible].get_books() |
927 | @@ -229,10 +230,10 @@ |
928 | def get_chapter_count(self, bible, book): |
929 | """ |
930 | Returns the number of Chapters for a given book. |
931 | - |
932 | + |
933 | ``bible`` |
934 | Unicode. The Bible to get the list of books from. |
935 | - |
936 | + |
937 | ``book`` |
938 | The book object to get the chapter count for. |
939 | """ |
940 | @@ -295,7 +296,7 @@ |
941 | if db_book: |
942 | book_id = db_book.book_reference_id |
943 | log.debug(u'Book name corrected to "%s"', db_book.name) |
944 | - new_reflist.append((book_id, item[1], item[2], |
945 | + new_reflist.append((book_id, item[1], item[2], |
946 | item[3])) |
947 | else: |
948 | log.debug(u'OpenLP failed to find book %s', item[0]) |
949 | |
950 | === modified file 'openlp/plugins/bibles/lib/mediaitem.py' |
951 | --- openlp/plugins/bibles/lib/mediaitem.py 2011-08-13 10:49:53 +0000 |
952 | +++ openlp/plugins/bibles/lib/mediaitem.py 2011-08-17 10:17:27 +0000 |
953 | @@ -613,7 +613,7 @@ |
954 | if restore: |
955 | old_text = unicode(combo.currentText()) |
956 | combo.clear() |
957 | - combo.addItems([unicode(i) for i in range(range_from, range_to + 1)]) |
958 | + combo.addItems(map(unicode, range(range_from, range_to + 1))) |
959 | if restore and combo.findText(old_text) != -1: |
960 | combo.setCurrentIndex(combo.findText(old_text)) |
961 | |
962 | |
963 | === modified file 'openlp/plugins/songs/lib/openlyricsexport.py' |
964 | --- openlp/plugins/songs/lib/openlyricsexport.py 2011-06-19 21:11:29 +0000 |
965 | +++ openlp/plugins/songs/lib/openlyricsexport.py 2011-08-17 10:17:27 +0000 |
966 | @@ -35,6 +35,7 @@ |
967 | from lxml import etree |
968 | |
969 | from openlp.core.lib import check_directory_exists, Receiver, translate |
970 | +from openlp.core.utils import clean_filename |
971 | from openlp.plugins.songs.lib import OpenLyrics |
972 | |
973 | log = logging.getLogger(__name__) |
974 | @@ -72,8 +73,7 @@ |
975 | tree = etree.ElementTree(etree.fromstring(xml)) |
976 | filename = u'%s (%s)' % (song.title, |
977 | u', '.join([author.display_name for author in song.authors])) |
978 | - filename = re.sub( |
979 | - r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_') |
980 | + filename = clean_filename(filename) |
981 | # Ensure the filename isn't too long for some filesystems |
982 | filename = u'%s.xml' % filename[0:250 - len(self.save_path)] |
983 | # Pass a file object, because lxml does not cope with some special |
Creation of temp dir name shouls be common to easy for one to be changed and rest missed