forked from openlp/openlp
Explicitly declare exceptions
This commit is contained in:
parent
dc96d471e6
commit
4616bbcb36
@ -120,7 +120,7 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
try:
|
||||
if self.icons[title]:
|
||||
return self.icons[title]
|
||||
except:
|
||||
except NameError:
|
||||
log.exception(u'getIconFromTitle - no icon for %s' % title)
|
||||
return QtGui.QIcon()
|
||||
|
||||
|
@ -590,7 +590,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
zip.close()
|
||||
try:
|
||||
os.remove(servicefile)
|
||||
except IOError:
|
||||
except (IOError, OSError):
|
||||
pass #if not present do not worry
|
||||
name = filename.split(os.path.sep)
|
||||
self.serviceName = name[-1]
|
||||
@ -668,7 +668,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
try:
|
||||
if os.path.isfile(p_file):
|
||||
os.remove(p_file)
|
||||
except IOError:
|
||||
except (IOError, OSError):
|
||||
log.exception(u'Failed to remove osd file')
|
||||
except IOError:
|
||||
log.exception(u'Problem loading a service file')
|
||||
@ -701,7 +701,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
except:
|
||||
except OSError:
|
||||
log.exception(u'Failed to clean up servicePath')
|
||||
|
||||
def onThemeComboBoxSelected(self, currentIndex):
|
||||
|
@ -203,7 +203,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
os.remove(os.path.join(self.path, th))
|
||||
os.remove(os.path.join(self.thumbPath, th))
|
||||
shutil.rmtree(os.path.join(self.path, theme))
|
||||
except:
|
||||
except OSError:
|
||||
#if not present do not worry
|
||||
pass
|
||||
# As we do not reload the themes push out the change
|
||||
@ -238,7 +238,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
zip.write(
|
||||
os.path.join(source, name),
|
||||
os.path.join(theme, name))
|
||||
except:
|
||||
except (IOError, OSError):
|
||||
log.exception(u'Export Theme Failed')
|
||||
finally:
|
||||
if zip:
|
||||
@ -358,11 +358,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
outfile = open(fullpath, u'wb')
|
||||
outfile.write(zip.read(file))
|
||||
self.generateAndSaveImage(dir, themename, filexml)
|
||||
except:
|
||||
except IOError:
|
||||
QtGui.QMessageBox.critical(
|
||||
self, self.trUtf8('Error'),
|
||||
self.trUtf8('File is not a valid theme.'),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||
self.trUtf8('File is not a valid theme.'))
|
||||
log.exception(u'Importing theme from zip file failed %s' % filename)
|
||||
finally:
|
||||
if zip:
|
||||
@ -454,7 +453,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
try:
|
||||
outfile = open(theme_file, u'w')
|
||||
outfile.write(theme_pretty_xml)
|
||||
except:
|
||||
except IOError:
|
||||
log.exception(u'Saving theme to file failed')
|
||||
finally:
|
||||
if outfile:
|
||||
@ -462,7 +461,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
if image_from and image_from != image_to:
|
||||
try:
|
||||
shutil.copyfile(image_from, image_to)
|
||||
except:
|
||||
except IOError:
|
||||
log.exception(u'Failed to save theme image')
|
||||
self.generateAndSaveImage(self.path, name, theme_xml)
|
||||
self.loadThemes()
|
||||
|
@ -143,7 +143,7 @@ class MigrateBibles(object):
|
||||
try:
|
||||
self.session.add(testament)
|
||||
self.session.commit()
|
||||
except:
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
print u'Error thrown = ', sys.exc_info()[1]
|
||||
self.progress(u'Create book table')
|
||||
@ -157,7 +157,7 @@ class MigrateBibles(object):
|
||||
try:
|
||||
self.session.add(book)
|
||||
self.session.commit()
|
||||
except:
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
print u'Error thrown = ', sys.exc_info()[1]
|
||||
self.progress(u'Create verse table')
|
||||
@ -171,14 +171,10 @@ class MigrateBibles(object):
|
||||
verse.text = verse_temp.text
|
||||
try:
|
||||
self.session.add(verse)
|
||||
except:
|
||||
self.session.commit()
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
print u'Error thrown = ', sys.exc_info()[1]
|
||||
try:
|
||||
self.session.commit()
|
||||
except:
|
||||
self.session.rollback()
|
||||
print u'Error thrown = ', sys.exc_info()[1]
|
||||
self.progress(u'Create metadata table')
|
||||
results = self.session.query(TBibleMeta).order_by(TBibleMeta.key).all()
|
||||
for biblemeta_temp in results:
|
||||
@ -188,7 +184,7 @@ class MigrateBibles(object):
|
||||
try:
|
||||
self.session.add(biblemeta)
|
||||
self.session.commit()
|
||||
except:
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
print u'Error thrown = ', sys.exc_info()[1]
|
||||
|
||||
@ -206,3 +202,4 @@ class MigrateBibles(object):
|
||||
conn.commit()
|
||||
conn.execute(u'vacuum;')
|
||||
conn.commit()
|
||||
|
||||
|
@ -159,7 +159,7 @@ class MigrateSongs(object):
|
||||
try:
|
||||
self.session.add(song)
|
||||
self.session.commit()
|
||||
except:
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
print u'Error thrown = ', sys.exc_info()[1]
|
||||
|
||||
|
@ -80,7 +80,7 @@ class DBManager(object):
|
||||
self.session.commit()
|
||||
log.debug(u'Alert saved')
|
||||
return True
|
||||
except:
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
log.exception(u'Alert save failed')
|
||||
return False
|
||||
@ -104,7 +104,7 @@ class DBManager(object):
|
||||
self.session.delete(alert_item)
|
||||
self.session.commit()
|
||||
return True
|
||||
except:
|
||||
except InvalidRequestError:
|
||||
self.session.rollback()
|
||||
log.exception(u'Alert deleton failed')
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user