Merge lp:~sam92/openlp/bug-1326664-2.0 into lp:openlp/2.0

Proposed by Samuel Mehrbrodt
Status: Merged
Approved by: Tim Bentley
Approved revision: 2198
Merged at revision: 2196
Proposed branch: lp:~sam92/openlp/bug-1326664-2.0
Merge into: lp:openlp/2.0
Diff against target: 50 lines (+17/-3)
1 file modified
openlp/plugins/songs/lib/ewimport.py (+17/-3)
To merge this branch: bzr merge lp:~sam92/openlp/bug-1326664-2.0
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Raoul Snyman Approve
Review via email: mp+222746@code.launchpad.net

This proposal supersedes a proposal from 2014-06-09.

Description of the change

Add proper error messages to EasyWorship import.
Also make sure that Songs.db (lowercase ending) is also being recognized.

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) : Posted in a previous version of this proposal
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

<samuel_m> superfly, concerning https://code.launchpad.net/~sam92/openlp/bug-1326664-2.0/+merge/222473 : The log is presented to the user with first the file name and then the error message. So it doesn't make much sense to include the filename in the error message.

review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Sorry to go back on my approval, could you just change the "This file is not a valid EasyWorship database." strings please?

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/plugins/songs/lib/ewimport.py'
--- openlp/plugins/songs/lib/ewimport.py 2014-05-20 16:19:06 +0000
+++ openlp/plugins/songs/lib/ewimport.py 2014-06-11 05:26:57 +0000
@@ -64,13 +64,23 @@
6464
65 def doImport(self):65 def doImport(self):
66 # Open the DB and MB files if they exist66 # Open the DB and MB files if they exist
67 import_source_mb = self.importSource.replace('.DB', '.MB')67 import_source_mb = self.importSource.replace('.DB', '.MB').replace('.db', '.mb')
68 if not os.path.isfile(self.importSource):68 if not os.path.isfile(self.importSource):
69 self.logError(self.importSource, translate(
70 'SongsPlugin.EasyWorshipSongImport',
71 'This file does not exist.'))
69 return72 return
70 if not os.path.isfile(import_source_mb):73 if not os.path.isfile(import_source_mb):
74 self.logError(self.importSource, translate(
75 'SongsPlugin.EasyWorshipSongImport',
76 'Could not find the "Songs.MB" file. It must be in the same '
77 'folder as the "Songs.DB" file.'))
71 return78 return
72 db_size = os.path.getsize(self.importSource)79 db_size = os.path.getsize(self.importSource)
73 if db_size < 0x800:80 if db_size < 0x800:
81 self.logError(self.importSource, translate(
82 'SongsPlugin.EasyWorshipSongImport',
83 'This file is not a valid EasyWorship database.'))
74 return84 return
75 db_file = open(self.importSource, 'rb')85 db_file = open(self.importSource, 'rb')
76 self.memoFile = open(import_source_mb, 'rb')86 self.memoFile = open(import_source_mb, 'rb')
@@ -80,6 +90,9 @@
80 if header_size != 0x800 or block_size < 1 or block_size > 4:90 if header_size != 0x800 or block_size < 1 or block_size > 4:
81 db_file.close()91 db_file.close()
82 self.memoFile.close()92 self.memoFile.close()
93 self.logError(self.importSource, translate(
94 'SongsPlugin.EasyWorshipSongImport',
95 'This file is not a valid EasyWorship database.'))
83 return96 return
84 # Take a stab at how text is encoded97 # Take a stab at how text is encoded
85 self.encoding = u'cp1252'98 self.encoding = u'cp1252'
@@ -193,8 +206,9 @@
193 result = strip_rtf(words, self.encoding)206 result = strip_rtf(words, self.encoding)
194 except UnicodeDecodeError:207 except UnicodeDecodeError:
195 # The unicode chars in the rtf was not escaped in the expected manner.208 # The unicode chars in the rtf was not escaped in the expected manner.
196 self.logError(self.title, unicode(translate('SongsPlugin.EasyWorshipSongImport',209 self.logError(self.title, unicode(translate(
197 'Unexpected data formatting.')))210 'SongsPlugin.EasyWorshipSongImport',
211 'Unexpected data formatting.')))
198 continue212 continue
199 if result is None:213 if result is None:
200 return214 return

Subscribers

People subscribed via source and target branches