Make sure not to catch keyboard interrupts and system exits
This commit is contained in:
@@ -86,6 +86,8 @@ class CharacterImportThread(threading.Thread):
|
||||
)
|
||||
char = sCharacter.new(name + " (EVEMon)")
|
||||
sCharacter.apiUpdateCharSheet(char.ID, skills, securitystatus)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.error("Exception on character import:")
|
||||
pyfalog.error(e)
|
||||
@@ -151,6 +153,8 @@ class Character:
|
||||
data += "Skills required for {}:\n".format(item)
|
||||
data += "{}{}: {}\n".format(" " * s["indent"], s["skill"], int(s["level"]))
|
||||
data += "-" * 79 + "\n"
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -496,6 +500,8 @@ class UpdateAPIThread(threading.Thread):
|
||||
char.secStatus = resp['security_status']
|
||||
|
||||
self.callback[0](self.callback[1])
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as ex:
|
||||
pyfalog.warn(ex)
|
||||
self.callback[0](self.callback[1], sys.exc_info())
|
||||
|
||||
@@ -110,6 +110,8 @@ class ImplantSets:
|
||||
else:
|
||||
item = sMkt.getItem(line)
|
||||
current.implants.append(es_Implant(item))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
errors += 1
|
||||
continue
|
||||
|
||||
@@ -68,12 +68,16 @@ class ShipBrowserWorkerThread(threading.Thread):
|
||||
cache[id_] = set_
|
||||
|
||||
wx.CallAfter(callback, (id_, set_))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.critical("Callback failed.")
|
||||
pyfalog.critical(e)
|
||||
finally:
|
||||
try:
|
||||
queue.task_done()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.critical("Queue task done failed.")
|
||||
pyfalog.critical(e)
|
||||
@@ -403,6 +407,8 @@ class Market:
|
||||
item = eos.db.getItem(id_, *args, **kwargs)
|
||||
else:
|
||||
raise TypeError("Need Item object, integer, float or string as argument")
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.error("Could not get item: {0}", identity)
|
||||
raise
|
||||
|
||||
@@ -92,6 +92,8 @@ class Network:
|
||||
raise Error(error)
|
||||
except requests.exceptions.Timeout:
|
||||
raise TimeoutError()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as error:
|
||||
raise Error(error)
|
||||
|
||||
@@ -117,6 +119,8 @@ class Network:
|
||||
raise Error(error)
|
||||
except requests.exceptions.Timeout:
|
||||
raise TimeoutError()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as error:
|
||||
raise Error(error)
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ def importDna(string, fitName=None):
|
||||
Citadel(sMkt.getItem(id_))
|
||||
string = string[string.index(str(id_)):]
|
||||
break
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Exception caught in importDna")
|
||||
pass
|
||||
@@ -107,6 +109,8 @@ def importDna(string, fitName=None):
|
||||
for i in range(int(amount)):
|
||||
try:
|
||||
m = Module(item)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Exception caught in importDna")
|
||||
continue
|
||||
|
||||
@@ -269,6 +269,8 @@ class EfsPort:
|
||||
else:
|
||||
modTypeIDSets[mod.slot].append(0)
|
||||
moduleNameSets[mod.slot].append("Empty Slot")
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.error("Could not find name for module {0}".format(vars(mod)))
|
||||
|
||||
|
||||
@@ -321,6 +321,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
sMkt = Market.getInstance()
|
||||
try:
|
||||
sMkt.getItem(shipname)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
return [] # empty list is expected
|
||||
|
||||
@@ -377,6 +379,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
# Bail if we can't get item or it's not from drone category
|
||||
try:
|
||||
droneItem = sMkt.getItem(droneName, eager="group.category")
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Cannot get item.")
|
||||
continue
|
||||
@@ -399,6 +403,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
# Bail if we can't get item or it's not from implant category
|
||||
try:
|
||||
implantItem = sMkt.getItem(entityData, eager="group.category")
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Cannot get item.")
|
||||
continue
|
||||
@@ -415,6 +421,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
# Bail if we can't get item or it's not from implant category
|
||||
try:
|
||||
boosterItem = sMkt.getItem(entityData, eager="group.category")
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Cannot get item.")
|
||||
continue
|
||||
@@ -436,6 +444,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
# Bail if we can't get item
|
||||
try:
|
||||
item = sMkt.getItem(cargoName)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Cannot get item.")
|
||||
continue
|
||||
@@ -453,6 +463,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
# If we can't get module item, skip it
|
||||
try:
|
||||
modItem = sMkt.getItem(modName)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Cannot get item.")
|
||||
continue
|
||||
@@ -475,6 +487,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
chargeItem = sMkt.getItem(chargeName, eager="group.category")
|
||||
if chargeItem.category.name == "Charge":
|
||||
m.charge = chargeItem
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Cannot get item.")
|
||||
pass
|
||||
@@ -499,6 +513,8 @@ def importEftCfg(shipname, lines, iportuser):
|
||||
"%s:\n%s" % (fitobj.ship.name, fitobj.name)
|
||||
)
|
||||
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
# Skip fit silently if we get an exception
|
||||
except Exception as e:
|
||||
pyfalog.error("Caught exception on fit.")
|
||||
@@ -593,6 +609,8 @@ def _importCreateFit(lines):
|
||||
except ValueError:
|
||||
fit.ship = Citadel(ship)
|
||||
fit.name = fitName
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning('service.port.eft.importEft: exception caught when parsing header')
|
||||
raise EftImportError
|
||||
|
||||
@@ -161,6 +161,8 @@ def importESI(string):
|
||||
fitobj.ship = Ship(sMkt.getItem(ship))
|
||||
except ValueError:
|
||||
fitobj.ship = Citadel(sMkt.getItem(ship))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Caught exception in importESI")
|
||||
return None
|
||||
@@ -201,6 +203,8 @@ def importESI(string):
|
||||
|
||||
moduleList.append(m)
|
||||
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pyfalog.warning("Could not process module.")
|
||||
continue
|
||||
|
||||
@@ -177,6 +177,8 @@ class Port:
|
||||
|
||||
except UserCancelException:
|
||||
return False, "Processing has been canceled.\n"
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.critical("Unknown exception processing: {0}", path)
|
||||
pyfalog.critical(e)
|
||||
@@ -253,6 +255,8 @@ class Port:
|
||||
# Try to import mutated module
|
||||
try:
|
||||
baseItem, mutaplasmidItem, mutations = parseMutant(lines)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
|
||||
@@ -84,6 +84,8 @@ def _resolve_ship(fitting, sMkt, b_localized):
|
||||
ship = Ship(sMkt.getItem(shipType))
|
||||
except ValueError:
|
||||
ship = Citadel(sMkt.getItem(shipType))
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.warning("Caught exception on _resolve_ship")
|
||||
pyfalog.error(e)
|
||||
@@ -128,6 +130,8 @@ def _resolve_module(hardware, sMkt, b_localized):
|
||||
must_retry = False
|
||||
try:
|
||||
item = sMkt.getItem(moduleName, eager="group.category")
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.warning("Caught exception on _resolve_module")
|
||||
pyfalog.error(e)
|
||||
@@ -158,6 +162,8 @@ def importXml(text, iportuser):
|
||||
for fitting in fittings:
|
||||
try:
|
||||
fitobj = _resolve_ship(fitting, sMkt, b_localized)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
failed += 1
|
||||
continue
|
||||
@@ -264,6 +270,8 @@ def exportXml(fits, iportuser, callback):
|
||||
description.setAttribute(
|
||||
"value", re.sub("(\r|\n|\r\n)+", "<br>", notes) if notes is not None else ""
|
||||
)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.warning("read description is failed, msg=%s\n" % e.args)
|
||||
|
||||
@@ -328,6 +336,8 @@ def exportXml(fits, iportuser, callback):
|
||||
hardware.setAttribute("slot", "cargo")
|
||||
hardware.setAttribute("type", name)
|
||||
fitting.appendChild(hardware)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.error("Failed on fitID: %d, message: %s" % e.message)
|
||||
continue
|
||||
|
||||
@@ -17,6 +17,8 @@ class PreCheckMessage:
|
||||
app = wx.App(False)
|
||||
wx.MessageBox(msg, 'Error', wx.ICON_ERROR | wx.STAY_ON_TOP)
|
||||
app.MainLoop()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
@@ -45,6 +47,8 @@ def version_precheck():
|
||||
|
||||
import wx
|
||||
version_block += "\nwxPython version: {} ({})".format(VERSION_STRING, wx.wxWidgets_version)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
msg = "pyfa requires wxPython v4.0.0b2+. You can download wxPython from https://wxpython.org/pages/downloads/"
|
||||
raise PreCheckException(msg)
|
||||
@@ -56,6 +60,8 @@ def version_precheck():
|
||||
|
||||
if (int(saMatch.group(1)), int(saMatch.group(2)), int(saMatch.group(3))) < (1, 0, 5):
|
||||
raise Exception()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
msg = "pyfa requires SQLAlchemy v1.0.5+. You can download SQLAlchemy from https://www.sqlalchemy.org/download.html"
|
||||
raise PreCheckException(msg)
|
||||
@@ -67,12 +73,16 @@ def version_precheck():
|
||||
|
||||
if int(logVersion[0]) < 1:
|
||||
raise Exception()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
raise PreCheckException("pyfa requires Logbook version 1.0.0+. You can download Logbook from https://pypi.python.org/pypi/Logbook")
|
||||
|
||||
try:
|
||||
import requests
|
||||
version_block += "\nRequests version: {}".format(requests.__version__)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
msg = "pyfa requires the requests module. You can download requests from https://pypi.python.org/pypi/requests"
|
||||
raise PreCheckException(msg)
|
||||
@@ -80,6 +90,8 @@ def version_precheck():
|
||||
try:
|
||||
import dateutil
|
||||
version_block += "\nDateutil version: {}".format(dateutil.__version__)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
msg = "pyfa requires the python-dateutil module. You can download python-dateutil form https://pypi.python.org/pypi/python-dateutil"
|
||||
raise PreCheckException(msg)
|
||||
|
||||
@@ -131,6 +131,8 @@ class Price:
|
||||
except TimeoutError:
|
||||
pyfalog.warning("Price fetch timeout for source {}".format(source))
|
||||
timedOutSources[source] = True
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.warn('Failed to fetch prices from price source {}: {}'.format(source, e))
|
||||
# Sources remove price map items as they fetch info, if none remain then we're done
|
||||
@@ -176,6 +178,8 @@ class Price:
|
||||
def cb():
|
||||
try:
|
||||
callback(requests)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.critical("Execution of callback from getPrices failed.")
|
||||
pyfalog.critical(e)
|
||||
@@ -211,6 +215,8 @@ class Price:
|
||||
replacementsCheaper[replacee] = replacer
|
||||
try:
|
||||
callback(replacementsCheaper)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.critical("Execution of callback from findCheaperReplacements failed.")
|
||||
pyfalog.critical(e)
|
||||
|
||||
@@ -88,6 +88,8 @@ class AuthHandler(http.server.BaseHTTPRequestHandler):
|
||||
# For implicit mode, we have to serve up the page which will take the hash and redirect using a querystring
|
||||
pyfalog.info("Processing response from EVE Online.")
|
||||
msg = "Processing response from EVE Online"
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as ex:
|
||||
pyfalog.error("Error logging into EVE")
|
||||
pyfalog.error(ex)
|
||||
|
||||
@@ -69,6 +69,8 @@ class SettingsProvider:
|
||||
for item in defaults:
|
||||
if item not in info:
|
||||
info[item] = defaults[item]
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
info = {}
|
||||
info.update(defaults)
|
||||
|
||||
@@ -50,6 +50,8 @@ class CheckUpdateThread(threading.Thread):
|
||||
response = network.get(
|
||||
url='https://www.pyfa.io/update_check?pyfa_version={}&client_hash={}'.format(config.version, config.getClientSecret()),
|
||||
type=network.UPDATE)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
response = network.get(
|
||||
url='https://api.github.com/repos/pyfa-org/Pyfa/releases',
|
||||
@@ -81,6 +83,8 @@ class CheckUpdateThread(threading.Thread):
|
||||
wx.CallAfter(self.callback, release, rVersion)
|
||||
break
|
||||
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except Exception as e:
|
||||
pyfalog.error("Caught exception in run")
|
||||
pyfalog.error(e)
|
||||
|
||||
Reference in New Issue
Block a user