do not override the file class

This commit is contained in:
Andreas Preikschat 2011-06-01 07:42:56 +02:00
parent 6c1c4c91bb
commit 4ce960d0cc
3 changed files with 14 additions and 14 deletions

View File

@ -106,7 +106,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
"""
Saving exception log and system informations to a file.
"""
report = unicode(translate('OpenLP.ExceptionForm',
report_text = unicode(translate('OpenLP.ExceptionForm',
'**OpenLP Bug Report**\n'
'Version: %s\n\n'
'--- Details of the Exception. ---\n\n%s\n\n '
@ -122,21 +122,21 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
filename = unicode(QtCore.QDir.toNativeSeparators(filename))
SettingsManager.set_last_dir(self.settingsSection, os.path.dirname(
filename))
report = report % self._createReport()
report_text = report_text % self._createReport()
try:
file = open(filename, u'w')
report_file = open(filename, u'w')
try:
file.write(report)
report_file.write(report_text)
except UnicodeError:
file.close()
file = open(filename, u'wb')
file.write(report.encode(u'utf-8'))
report_file.close()
report_file = open(filename, u'wb')
report_file.write(report_text.encode(u'utf-8'))
finally:
file.close()
report_file.close()
except IOError:
log.exception(u'Failed to write crash report')
finally:
file.close()
report_file.close()
def onSendReportButtonPressed(self):
"""

View File

@ -772,9 +772,9 @@ class SongImportForm(OpenLPWizard):
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
if not filename:
return
file = codecs.open(filename, u'w', u'utf-8')
file.write(self.errorReportTextEdit.toPlainText())
file.close()
report_file = codecs.open(filename, u'w', u'utf-8')
report_file.write(self.errorReportTextEdit.toPlainText())
report_file.close()
def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False,
single_select=False):

View File

@ -61,8 +61,8 @@ class EasiSlidesImport(SongImport):
"""
log.info(u'Importing EasiSlides XML file %s', self.import_source)
parser = etree.XMLParser(remove_blank_text=True)
file = etree.parse(self.import_source, parser)
xml = unicode(etree.tostring(file))
parsed_file = etree.parse(self.import_source, parser)
xml = unicode(etree.tostring(parsed_file))
song_xml = objectify.fromstring(xml)
self.import_wizard.progressBar.setMaximum(len(song_xml.Item))
for song in song_xml.Item: