Make sure not to catch keyboard interrupts and system exits

This commit is contained in:
DarkPhoenix
2020-02-03 16:12:41 +03:00
parent f22a4f13e5
commit 9ddfcc894f
42 changed files with 171 additions and 3 deletions

View File

@@ -112,6 +112,8 @@ class ItemAffectedBy(wx.Panel):
else:
try:
self.affectedBy.CollapseAll()
except (KeyboardInterrupt, SystemExit):
raise
except:
pass

View File

@@ -86,6 +86,8 @@ class ItemProperties(wx.Panel):
valueUnit = str(value)
self.paramList.SetItem(index, 1, valueUnit)
except (KeyboardInterrupt, SystemExit):
raise
except:
# TODO: Add logging to this.
# We couldn't get a property for some reason. Skip it for now.

View File

@@ -63,6 +63,8 @@ class MarketTree(wx.TreeCtrl):
iconId = self.addImage(sMkt.getIconByMarketGroup(childMktGrp))
try:
childId = self.AppendItem(root, childMktGrp.name, iconId, data=childMktGrp.ID)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.debug("Error appending item.")
pyfalog.debug(e)

View File

@@ -66,6 +66,8 @@ class FitSpawner(gui.multiSwitch.TabSpawner):
self.multiSwitch.SetSelection(index)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(event.fitID,)))
break
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.critical("Caught exception in fitSelected")
pyfalog.critical(e)
@@ -812,6 +814,8 @@ class FittingView(d.Display):
if self and not self.IsShown():
try:
self.MakeSnapshot()
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.critical("Failed to make snapshot")
pyfalog.critical(e)
@@ -837,6 +841,8 @@ class FittingView(d.Display):
sFit = Fit.getInstance()
try:
fit = sFit.getFit(self.activeFitID)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.critical("Failed to get fit")
pyfalog.critical(e)

View File

@@ -475,6 +475,8 @@ class SkillTreeView(wx.Panel):
if skill:
skill.setLevel(level, ignoreRestrict=True)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.error(e)
with wx.MessageDialog(self, "There was an error importing skills, please see log file", "Error", wx.ICON_ERROR) as dlg:

View File

@@ -1138,6 +1138,8 @@ class _TabsContainer(wx.Panel):
self.preview_tab = tab
self.preview_timer.Start(500, True)
break
except (KeyboardInterrupt, SystemExit):
raise
except:
pass

View File

@@ -125,6 +125,8 @@ class EveFittings(AuxiliaryFrame):
# Can't do this in a finally because then it obscures the message dialog
del waitDialog # noqa: F821
ESIExceptionHandler(self, ex)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as ex:
del waitDialog # noqa: F821
raise ex
@@ -302,6 +304,8 @@ class ExportToEve(AuxiliaryFrame):
except APIException as ex:
try:
ESIExceptionHandler(self, ex)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as ex:
self.statusbar.SetStatusText("ERROR", 0)
self.statusbar.SetStatusText("{} - {}".format(res.status_code, res.reason), 1)
@@ -381,6 +385,8 @@ class SsoCharacterMgmt(AuxiliaryFrame):
try:
sEsi = Esi.getInstance()
sEsi.login()
except (KeyboardInterrupt, SystemExit):
raise
except Exception as ex:
ESIServerExceptionHandler(self, ex)
@@ -457,6 +463,8 @@ class FittingsTreeView(wx.Panel):
cargo = Cargo(getItem(item['type_id']))
cargo.amount = item['quantity']
list.append(cargo)
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.critical("Exception caught in displayFit")
pyfalog.critical(e)

View File

@@ -251,6 +251,8 @@ class MainFrame(wx.Frame):
fit = sFit.getFit(id, basic=True)
if fit is None:
fits.remove(id)
except (KeyboardInterrupt, SystemExit):
raise
except:
fits.remove(id)
@@ -774,6 +776,8 @@ class MainFrame(wx.Frame):
if self.command.Submit(cmd.GuiImportCargosCommand(activeFit, [(i.ID, a) for i, a in importData[0]])):
self.additionsPane.select("Cargo")
return
except (KeyboardInterrupt, SystemExit):
raise
except:
pyfalog.error("Attempt to import failed:\n{0}", clipboard)
else:

View File

@@ -265,6 +265,8 @@ class DmgPatternEditor(AuxiliaryFrame):
except ImportError as e:
pyfalog.error(e)
self.stNotice.SetLabel(str(e))
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
msg = "Could not import from clipboard: unknown errors"
pyfalog.warning(msg)

View File

@@ -211,6 +211,8 @@ class ImplantSetEditor(AuxiliaryFrame):
except ImportError as e:
pyfalog.error(e)
self.stNotice.SetLabel(str(e))
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
pyfalog.error(e)
self.stNotice.SetLabel("Could not import from clipboard: unknown errors")

View File

@@ -352,6 +352,8 @@ class TargetProfileEditor(AuxiliaryFrame):
except ImportError as e:
pyfalog.error(e)
self.stNotice.SetLabel(str(e))
except (KeyboardInterrupt, SystemExit):
raise
except Exception as e:
msg = "Could not import from clipboard:"
pyfalog.warning(msg)

View File

@@ -70,6 +70,8 @@ class exportHtmlThread(threading.Thread):
except IOError as ex:
pyfalog.warning("Failed to write to " + settings.getPath())
pass
except (KeyboardInterrupt, SystemExit):
raise
except Exception as ex:
pass
@@ -226,6 +228,8 @@ class exportHtmlThread(threading.Thread):
HTMLfit += ' </ul>\n </li>\n'
HTMLship += HTMLfit
except (KeyboardInterrupt, SystemExit):
raise
except:
pyfalog.warning("Failed to export line")
continue
@@ -281,6 +285,8 @@ class exportHtmlThread(threading.Thread):
HTML += '<a class="outOfGameBrowserLink" target="_blank" href="' + dnaUrl + dnaFit + '">' \
+ ship.name + ': ' + \
fit[1] + '</a><br> \n'
except (KeyboardInterrupt, SystemExit):
raise
except:
pyfalog.error("Failed to export line")
continue