Give proper error messages in EW Import

Fixes: https://launchpad.net/bugs/1326664
This commit is contained in:
Samuel Mehrbrodt 2014-06-09 10:07:13 +02:00
parent 31d7ec80ae
commit f79fe709b1
1 changed files with 11 additions and 1 deletions

View File

@ -64,13 +64,21 @@ class EasyWorshipSongImport(SongImport):
def doImport(self):
# Open the DB and MB files if they exist
import_source_mb = self.importSource.replace('.DB', '.MB')
import_source_mb = self.importSource.replace('.DB', '.MB').replace('.db', '.mb')
if not os.path.isfile(self.importSource):
self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport',
'This file does not exist.'))
return
return
if not os.path.isfile(import_source_mb):
self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport',
'Could not find the "Songs.MB" file. It must be in the same '
'folder as the "Songs.DB" file.'))
return
db_size = os.path.getsize(self.importSource)
if db_size < 0x800:
self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport',
'This file is no valid EasyWorship Database.'))
return
db_file = open(self.importSource, 'rb')
self.memoFile = open(import_source_mb, 'rb')
@ -80,6 +88,8 @@ class EasyWorshipSongImport(SongImport):
if header_size != 0x800 or block_size < 1 or block_size > 4:
db_file.close()
self.memoFile.close()
self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport',
'This file is no valid EasyWorship Database.'))
return
# Take a stab at how text is encoded
self.encoding = u'cp1252'