diff --git a/_development/helpers.py b/_development/helpers.py index 0840c793b6..6e0cbac030 100644 --- a/_development/helpers.py +++ b/_development/helpers.py @@ -49,6 +49,8 @@ class ReadOnlyException(Exception): gamedata_version = gamedata_session.execute( "SELECT `field_value` FROM `metadata` WHERE `field_name` LIKE 'client_build'" ).fetchone()[0] + except (KeyboardInterrupt, SystemExit): + raise except Exception as e: print("Missing gamedata version.") gamedata_version = None diff --git a/config.py b/config.py index 2991c3c070..91d9ff3ecb 100644 --- a/config.py +++ b/config.py @@ -233,6 +233,8 @@ def defLogging(): # reset=False, ) ]) + except (KeyboardInterrupt, SystemExit): + raise except: print("Critical error attempting to setup logging. Falling back to console only.") logging_setup = NestedSetup([ diff --git a/db_update.py b/db_update.py index d86e0b135b..2d54bd7134 100644 --- a/db_update.py +++ b/db_update.py @@ -40,7 +40,7 @@ def db_needs_update(): try: with open(os.path.join(JSON_DIR, 'phobos', 'metadata.json')) as f: data_version = next((r['field_value'] for r in json.load(f) if r['field_name'] == 'client_build')) - except KeyboardInterrupt: + except (KeyboardInterrupt, SystemExit): raise # If we have no source data - return None; should not update in this case except: @@ -61,7 +61,7 @@ def db_needs_update(): db_schema_version = int(row[0]) cursor.close() db.close() - except KeyboardInterrupt: + except (KeyboardInterrupt, SystemExit): raise except: print('Error when fetching gamedata DB metadata') diff --git a/eos/db/__init__.py b/eos/db/__init__.py index 262f2e7254..604e160862 100644 --- a/eos/db/__init__.py +++ b/eos/db/__init__.py @@ -56,6 +56,8 @@ class ReadOnlyException(Exception): config.gamedata_date = gamedata_session.execute( "SELECT `field_value` FROM `metadata` WHERE `field_name` LIKE 'dump_time'" ).fetchone()[0] +except (KeyboardInterrupt, SystemExit): + raise except Exception as e: pyfalog.warning("Missing gamedata version.") pyfalog.critical(e) diff --git a/eos/db/migrations/upgrade17.py b/eos/db/migrations/upgrade17.py index 0ea7463554..40139624fa 100644 --- a/eos/db/migrations/upgrade17.py +++ b/eos/db/migrations/upgrade17.py @@ -33,9 +33,13 @@ def upgrade(saveddata_engine): try: saveddata_session.execute(commandFits_table.insert(), {"boosterID": value, "boostedID": boosted, "active": 1}) + except (KeyboardInterrupt, SystemExit): + raise except Exception: pass saveddata_session.commit() + except (KeyboardInterrupt, SystemExit): + raise except: # Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version # If it does, simply fail. Fleet data migration isn't critically important here diff --git a/eos/db/migrations/upgrade25.py b/eos/db/migrations/upgrade25.py index 703048f372..b3a2ce124c 100644 --- a/eos/db/migrations/upgrade25.py +++ b/eos/db/migrations/upgrade25.py @@ -4235,6 +4235,8 @@ def upgrade(saveddata_engine): # And last but not least, delete the last subsystem saveddata_engine.execute("DELETE FROM modules WHERE ID = ?", (oldModules[4][0],)) + except (KeyboardInterrupt, SystemExit): + raise except: # if something fails, fuck it, we tried. It'll default to the generic conversion below continue diff --git a/eos/db/saveddata/queries.py b/eos/db/saveddata/queries.py index 9a454cf3b0..33439aa650 100644 --- a/eos/db/saveddata/queries.py +++ b/eos/db/saveddata/queries.py @@ -560,6 +560,8 @@ def commit(): with sd_lock: try: saveddata_session.commit() + except (KeyboardInterrupt, SystemExit): + raise except Exception: saveddata_session.rollback() exc_info = sys.exc_info() @@ -570,6 +572,8 @@ def flush(): with sd_lock: try: saveddata_session.flush() + except (KeyboardInterrupt, SystemExit): + raise except Exception: saveddata_session.rollback() exc_info = sys.exc_info() diff --git a/eos/effects.py b/eos/effects.py index 370d44d844..4e5e868176 100644 --- a/eos/effects.py +++ b/eos/effects.py @@ -32676,6 +32676,8 @@ def handler(fit, src, context, projectionRange, **kwargs): # via https://forums.eveonline.com/default.aspx?g=posts&t=515826 try: bonus = max(0, min(50.0, (src.owner.character.secStatus * 10))) + except (KeyboardInterrupt, SystemExit): + raise except: bonus = None diff --git a/eos/gamedata.py b/eos/gamedata.py index f1d6c6c198..372aacd764 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -184,6 +184,8 @@ def __generateHandler(self): self.__activeByDefault = True self.__type = None pyfalog.error("AttributeError generating handler: {0}", e) + except (KeyboardInterrupt, SystemExit): + raise except Exception as e: self.__handler = eos.effects.DummyEffect.handler self.__runTime = "normal" @@ -200,6 +202,8 @@ def getattr(self, key): try: return self.__effectDef.get(key, None) + except (KeyboardInterrupt, SystemExit): + raise except: return getattr(self.__effectDef, key, None) diff --git a/eos/saveddata/damagePattern.py b/eos/saveddata/damagePattern.py index 1952b5a049..bf6aeec72d 100644 --- a/eos/saveddata/damagePattern.py +++ b/eos/saveddata/damagePattern.py @@ -260,6 +260,8 @@ def importPatterns(cls, text): line = line.split('#', 1)[0] # allows for comments type, data = line.rsplit('=', 1) type, data = type.strip(), data.split(',') + except (KeyboardInterrupt, SystemExit): + raise except: # Data isn't in correct format, continue to next line continue @@ -274,6 +276,8 @@ def importPatterns(cls, text): for index, val in enumerate(data): try: fields["%sAmount" % cls.DAMAGE_TYPES[index]] = int(val) + except (KeyboardInterrupt, SystemExit): + raise except: continue diff --git a/eos/saveddata/mutator.py b/eos/saveddata/mutator.py index 07af6876f0..6353397aa6 100644 --- a/eos/saveddata/mutator.py +++ b/eos/saveddata/mutator.py @@ -73,6 +73,8 @@ def build(self): self.dynamicAttribute = next(a for a in self.module.mutaplasmid.attributes if a.attributeID == self.attrID) # base attribute links to the base ite's attribute for this mutated definition (contains original, base value) self.baseAttribute = self.module.item.attributes[self.dynamicAttribute.name] + except (KeyboardInterrupt, SystemExit): + raise except: self.module = None diff --git a/eos/saveddata/targetProfile.py b/eos/saveddata/targetProfile.py index dc94a2bef8..e2a816d528 100644 --- a/eos/saveddata/targetProfile.py +++ b/eos/saveddata/targetProfile.py @@ -294,6 +294,8 @@ def importPatterns(cls, text): line = line.split('#', 1)[0] # allows for comments type, data = line.rsplit('=', 1) type, data = type.strip(), [d.strip() for d in data.split(',')] + except (KeyboardInterrupt, SystemExit): + raise except: pyfalog.warning("Data isn't in correct format, continue to next line.") continue @@ -312,6 +314,8 @@ def importPatterns(cls, text): try: assert 0 <= val <= 100 fields["%sAmount" % cls.DAMAGE_TYPES[index]] = val / 100 + except (KeyboardInterrupt, SystemExit): + raise except: pyfalog.warning("Caught unhandled exception in import patterns.") continue diff --git a/graphs/gui/canvasPanel.py b/graphs/gui/canvasPanel.py index 3b846b5073..83b8a2ced3 100644 --- a/graphs/gui/canvasPanel.py +++ b/graphs/gui/canvasPanel.py @@ -54,6 +54,8 @@ except ImportError as e: pyfalog.warning('Matplotlib failed to import. Likely missing or incompatible version.') graphFrame_enabled = False +except (KeyboardInterrupt, SystemExit): + raise except Exception: # We can get exceptions deep within matplotlib. Catch those. See GH #1046 tb = traceback.format_exc() @@ -71,6 +73,8 @@ def __init__(self, graphFrame, parent): # Remove matplotlib font cache, see #234 try: cache_dir = mpl._get_cachedir() + except (KeyboardInterrupt, SystemExit): + raise except: cache_dir = os.path.expanduser(os.path.join('~', '.matplotlib')) cache_file = os.path.join(cache_dir, 'fontList.cache') @@ -168,6 +172,8 @@ def draw(self, accurateMarks=True): legendData.append((color, lineStyle, source.shortName)) else: legendData.append((color, lineStyle, '{} vs {}'.format(source.shortName, target.shortName))) + except (KeyboardInterrupt, SystemExit): + raise except Exception: pyfalog.warning('Failed to plot "{}" vs "{}"'.format(source.name, '' if target is None else target.name)) self.canvas.draw() @@ -241,6 +247,8 @@ def addYMark(val): src=source, tgt=target) addYMark(y) + except (KeyboardInterrupt, SystemExit): + raise except Exception: pyfalog.warning('Failed to get X mark for "{}" vs "{}"'.format(source.name, '' if target is None else target.name)) # Silently skip this mark, otherwise other marks and legend display will fail diff --git a/gui/builtinItemStatsViews/itemAffectedBy.py b/gui/builtinItemStatsViews/itemAffectedBy.py index 440e25c910..100cd17e38 100644 --- a/gui/builtinItemStatsViews/itemAffectedBy.py +++ b/gui/builtinItemStatsViews/itemAffectedBy.py @@ -112,6 +112,8 @@ def ExpandCollapseTree(self): else: try: self.affectedBy.CollapseAll() + except (KeyboardInterrupt, SystemExit): + raise except: pass diff --git a/gui/builtinItemStatsViews/itemProperties.py b/gui/builtinItemStatsViews/itemProperties.py index afc8c26457..ebf7c601fb 100644 --- a/gui/builtinItemStatsViews/itemProperties.py +++ b/gui/builtinItemStatsViews/itemProperties.py @@ -86,6 +86,8 @@ def PopulateList(self): 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. diff --git a/gui/builtinMarketBrowser/marketTree.py b/gui/builtinMarketBrowser/marketTree.py index 7f81530dde..5fe3cc83ef 100644 --- a/gui/builtinMarketBrowser/marketTree.py +++ b/gui/builtinMarketBrowser/marketTree.py @@ -63,6 +63,8 @@ def expandLookup(self, event): 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) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 75e8b15090..0c3088e3ed 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -66,6 +66,8 @@ def fitSelected(self, event): 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 @@ def OnShow(self, event): 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 @@ def MakeSnapshot(self, maxColumns=1337): 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) diff --git a/gui/characterEditor.py b/gui/characterEditor.py index bc4718324f..ddff34bdb0 100644 --- a/gui/characterEditor.py +++ b/gui/characterEditor.py @@ -475,6 +475,8 @@ def importSkills(self, evt): 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: diff --git a/gui/chrome_tabs.py b/gui/chrome_tabs.py index 229daa6dc5..8ca0f92a05 100644 --- a/gui/chrome_tabs.py +++ b/gui/chrome_tabs.py @@ -1138,6 +1138,8 @@ def CheckTabPreview(self, mposx, mposy): self.preview_tab = tab self.preview_timer.Start(500, True) break + except (KeyboardInterrupt, SystemExit): + raise except: pass diff --git a/gui/esiFittings.py b/gui/esiFittings.py index 22dec7a4ff..59bef316e7 100644 --- a/gui/esiFittings.py +++ b/gui/esiFittings.py @@ -125,6 +125,8 @@ def fetchFittings(self, event): # 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 @@ def exportFitting(self, event): 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 @@ def addChar(self, event): try: sEsi = Esi.getInstance() sEsi.login() + except (KeyboardInterrupt, SystemExit): + raise except Exception as ex: ESIServerExceptionHandler(self, ex) @@ -457,6 +463,8 @@ def displayFit(self, event): 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) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index c1b3f04a78..5883889343 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -251,6 +251,8 @@ def LoadPreviousOpenFits(self): 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 @@ def importFromClipboard(self, event): 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: diff --git a/gui/patternEditor.py b/gui/patternEditor.py index c2a6abfd0a..96bc8f97d1 100644 --- a/gui/patternEditor.py +++ b/gui/patternEditor.py @@ -265,6 +265,8 @@ def importPatterns(self, event): 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) diff --git a/gui/setEditor.py b/gui/setEditor.py index 807991a642..3c24b8f783 100644 --- a/gui/setEditor.py +++ b/gui/setEditor.py @@ -211,6 +211,8 @@ def importPatterns(self, event): 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") diff --git a/gui/targetProfileEditor.py b/gui/targetProfileEditor.py index e92e199c91..94701ad1cc 100644 --- a/gui/targetProfileEditor.py +++ b/gui/targetProfileEditor.py @@ -352,6 +352,8 @@ def importPatterns(self, event): 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) diff --git a/gui/utils/exportHtml.py b/gui/utils/exportHtml.py index 10df1947d0..1e429723d3 100644 --- a/gui/utils/exportHtml.py +++ b/gui/utils/exportHtml.py @@ -70,6 +70,8 @@ def run(self): 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 @@ def generateFullHTML(self, sMkt, sFit, dnaUrl): HTMLfit += ' \n \n' HTMLship += HTMLfit + except (KeyboardInterrupt, SystemExit): + raise except: pyfalog.warning("Failed to export line") continue @@ -281,6 +285,8 @@ def generateMinimalHTML(self, sMkt, sFit, dnaUrl): HTML += '' \ + ship.name + ': ' + \ fit[1] + '
\n' + except (KeyboardInterrupt, SystemExit): + raise except: pyfalog.error("Failed to export line") continue diff --git a/scripts/effectUsedBy.py b/scripts/effectUsedBy.py index 1b9ad26706..61a1cffc60 100755 --- a/scripts/effectUsedBy.py +++ b/scripts/effectUsedBy.py @@ -119,7 +119,7 @@ def calc_outerscore(innerscore_dict, pereffect_totalaffected, weight): def validate_string(s): try: s.encode('ascii') - except KeyboardInterrupt: + except (KeyboardInterrupt, SystemExit): raise except Exception: return False diff --git a/scripts/itemDiff.py b/scripts/itemDiff.py index 822b237f45..95f561954e 100755 --- a/scripts/itemDiff.py +++ b/scripts/itemDiff.py @@ -394,6 +394,8 @@ def getattrname(attr): new_cursor.execute(query) for row in new_cursor: new_meta[row[0]] = row[1] + except (KeyboardInterrupt, SystemExit): + raise except: pass # Print jobs diff --git a/service/character.py b/service/character.py index 28e0fc0085..6e8421468f 100644 --- a/service/character.py +++ b/service/character.py @@ -86,6 +86,8 @@ def run(self): ) 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 @@ def exportText(self): 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 @@ def run(self): 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()) diff --git a/service/implantSet.py b/service/implantSet.py index 913af613a0..090b9a9430 100644 --- a/service/implantSet.py +++ b/service/implantSet.py @@ -110,6 +110,8 @@ def importSets(self, text): else: item = sMkt.getItem(line) current.implants.append(es_Implant(item)) + except (KeyboardInterrupt, SystemExit): + raise except: errors += 1 continue diff --git a/service/market.py b/service/market.py index f8c45158a3..4856a1a63c 100644 --- a/service/market.py +++ b/service/market.py @@ -68,12 +68,16 @@ def processRequests(self): 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 @@ def getItem(identity, *args, **kwargs): 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 diff --git a/service/network.py b/service/network.py index 2c16980eac..2782da5f3c 100644 --- a/service/network.py +++ b/service/network.py @@ -92,6 +92,8 @@ def get(self, url, type, **kwargs): raise Error(error) except requests.exceptions.Timeout: raise TimeoutError() + except (KeyboardInterrupt, SystemExit): + raise except Exception as error: raise Error(error) @@ -117,6 +119,8 @@ def post(self, url, type, jsonData, **kwargs): raise Error(error) except requests.exceptions.Timeout: raise TimeoutError() + except (KeyboardInterrupt, SystemExit): + raise except Exception as error: raise Error(error) diff --git a/service/port/dna.py b/service/port/dna.py index 8f568fe883..5a1d7e3640 100644 --- a/service/port/dna.py +++ b/service/port/dna.py @@ -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 logtransform(s_): for i in range(int(amount)): try: m = Module(item) + except (KeyboardInterrupt, SystemExit): + raise except: pyfalog.warning("Exception caught in importDna") continue diff --git a/service/port/efs.py b/service/port/efs.py index 9ed5ef8feb..fbbb0969e8 100755 --- a/service/port/efs.py +++ b/service/port/efs.py @@ -269,6 +269,8 @@ def getModuleInfo(fit, padTypeIDs=False): 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))) diff --git a/service/port/eft.py b/service/port/eft.py index d0de5ab955..1f9e5c41bf 100644 --- a/service/port/eft.py +++ b/service/port/eft.py @@ -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 diff --git a/service/port/esi.py b/service/port/esi.py index c9296e1ecc..6794f301aa 100644 --- a/service/port/esi.py +++ b/service/port/esi.py @@ -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 diff --git a/service/port/port.py b/service/port/port.py index 6f61805ebe..210f8bf472 100644 --- a/service/port/port.py +++ b/service/port/port.py @@ -177,6 +177,8 @@ def importFitFromFiles(paths, iportuser=None): 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 @@ def importAuto(cls, string, path=None, activeFit=None, iportuser=None): # Try to import mutated module try: baseItem, mutaplasmidItem, mutations = parseMutant(lines) + except (KeyboardInterrupt, SystemExit): + raise except: pass else: diff --git a/service/port/xml.py b/service/port/xml.py index 1377e15d5a..88cdc9fb82 100644 --- a/service/port/xml.py +++ b/service/port/xml.py @@ -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)+", "
", 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 diff --git a/service/prereqsCheck.py b/service/prereqsCheck.py index 1594685914..3bbb1b81e6 100644 --- a/service/prereqsCheck.py +++ b/service/prereqsCheck.py @@ -17,6 +17,8 @@ def __init__(self, msg): 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) diff --git a/service/price.py b/service/price.py index 1bedc66e8f..d444025408 100644 --- a/service/price.py +++ b/service/price.py @@ -131,6 +131,8 @@ def fetchPrices(cls, prices, fetchTimeout, validityOverride): 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 @@ def getPrices(self, objitems, callback, fetchTimeout=30, waitforthread=False, va 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 @@ def makeCheapMapCb(requests): 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) diff --git a/service/server.py b/service/server.py index 31f235c044..8ec1ca607a 100644 --- a/service/server.py +++ b/service/server.py @@ -88,6 +88,8 @@ def do_GET(self): # 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) diff --git a/service/settings.py b/service/settings.py index fe5243566e..721f8ce6b0 100644 --- a/service/settings.py +++ b/service/settings.py @@ -69,6 +69,8 @@ def getSettings(self, area, defaults=None): for item in defaults: if item not in info: info[item] = defaults[item] + except (KeyboardInterrupt, SystemExit): + raise except: info = {} info.update(defaults) diff --git a/service/update.py b/service/update.py index 2560e6fce1..970ed84840 100644 --- a/service/update.py +++ b/service/update.py @@ -50,6 +50,8 @@ def run(self): 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 @@ def run(self): wx.CallAfter(self.callback, release, rVersion) break + except (KeyboardInterrupt, SystemExit): + raise except Exception as e: pyfalog.error("Caught exception in run") pyfalog.error(e)