From f010f2fef248f59ff87afdece1cc2038edf0164d Mon Sep 17 00:00:00 2001 From: blitzman Date: Sat, 28 Jan 2017 13:15:06 -0500 Subject: [PATCH 1/5] Don't loop through all amounts of cargo and drones just to get the price. (#958) --- gui/builtinStatsViews/priceViewFull.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gui/builtinStatsViews/priceViewFull.py b/gui/builtinStatsViews/priceViewFull.py index 16935a136..aae611ac6 100644 --- a/gui/builtinStatsViews/priceViewFull.py +++ b/gui/builtinStatsViews/priceViewFull.py @@ -81,16 +81,14 @@ class PriceViewFull(StatsView): typeIDs.append(mod.itemID) for drone in fit.drones: - for _ in xrange(drone.amount): - typeIDs.append(drone.itemID) + typeIDs.append(drone.itemID) for fighter in fit.fighters: - for _ in xrange(fighter.amountActive): + if fighter.amountActive > 0: typeIDs.append(fighter.itemID) for cargo in fit.cargo: - for _ in xrange(cargo.amount): - typeIDs.append(cargo.itemID) + typeIDs.append(cargo.itemID) sMkt = service.Market.getInstance() sMkt.getPrices(typeIDs, self.processPrices) From 6b6dacf94caa16a770f09f25870ecbd3378dbe04 Mon Sep 17 00:00:00 2001 From: blitzman Date: Sat, 28 Jan 2017 13:30:14 -0500 Subject: [PATCH 2/5] Fix traceback when trying to cancel an amount dialog with nothing in the field --- gui/builtinContextMenus/amount.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gui/builtinContextMenus/amount.py b/gui/builtinContextMenus/amount.py index 4ab98e694..79467e3a0 100644 --- a/gui/builtinContextMenus/amount.py +++ b/gui/builtinContextMenus/amount.py @@ -46,10 +46,15 @@ class AmountChanger(wx.Dialog): self.button.Bind(wx.EVT_BUTTON, self.change) def change(self, event): + if self.input.GetLineText(0).strip() == '': + event.Skip() + return + sFit = service.Fit.getInstance() mainFrame = gui.mainFrame.MainFrame.getInstance() fitID = mainFrame.getActiveFit() + print self.input.GetLineText(0), type(self.input.GetLineText(0)) if isinstance(self.thing, eos.types.Cargo): sFit.addCargo(fitID, self.thing.item.ID, int(float(self.input.GetLineText(0))), replace=True) elif isinstance(self.thing, eos.types.Fit): @@ -60,7 +65,6 @@ class AmountChanger(wx.Dialog): wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() - self.Close() ## checks to make sure it's valid number def onChar(self, event): From b3eb4f35cdb180e50cf3dc74d38fabcb723fdd0e Mon Sep 17 00:00:00 2001 From: blitzman Date: Sat, 28 Jan 2017 13:30:49 -0500 Subject: [PATCH 3/5] Max out cargo amount to sys.maxint (#958) --- eos/saveddata/cargo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/eos/saveddata/cargo.py b/eos/saveddata/cargo.py index 34ab42db3..4b82dfc33 100644 --- a/eos/saveddata/cargo.py +++ b/eos/saveddata/cargo.py @@ -17,6 +17,7 @@ # along with eos. If not, see . # =============================================================================== +import sys import logging from sqlalchemy.orm import validates, reconstructor @@ -68,10 +69,14 @@ class Cargo(HandledItem, ItemAttrShortcut): def clear(self): self.itemModifiedAttributes.clear() - @validates("fitID", "itemID") + @validates("fitID", "itemID", "amount") def validator(self, key, val): map = {"fitID": lambda val: isinstance(val, int), - "itemID": lambda val: isinstance(val, int)} + "itemID": lambda val: isinstance(val, int), + "amount": lambda val: isinstance(val, int)} + + if key == "amount" and val > sys.maxint: + val = sys.maxint if not map[key](val): raise ValueError(str(val) + " is not a valid value for " + key) From a76eef01de67a7b9daeb18c63f74013d2b0fb406 Mon Sep 17 00:00:00 2001 From: blitzman Date: Sat, 28 Jan 2017 17:46:59 -0500 Subject: [PATCH 4/5] name all ze threads --- gui/mainFrame.py | 1 + gui/utils/exportHtml.py | 1 + service/character.py | 2 ++ service/fit.py | 2 ++ service/market.py | 12 ++++++++++++ service/prefetch.py | 5 +++++ service/update.py | 1 + 7 files changed, 24 insertions(+) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 4c2b350a5..efde1a3ab 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -90,6 +90,7 @@ class PFPanel(wx.Panel): class OpenFitsThread(threading.Thread): def __init__(self, fits, callback): threading.Thread.__init__(self) + self.name = "LoadingOpenFits" self.mainFrame = MainFrame.getInstance() self.callback = callback self.fits = fits diff --git a/gui/utils/exportHtml.py b/gui/utils/exportHtml.py index 9fc20eff6..2e5834403 100644 --- a/gui/utils/exportHtml.py +++ b/gui/utils/exportHtml.py @@ -27,6 +27,7 @@ class exportHtmlThread(threading.Thread): def __init__(self, callback=False): threading.Thread.__init__(self) + self.name = "HTMLExport" self.callback = callback self.stopRunning = False diff --git a/service/character.py b/service/character.py index d439f1cd4..e69ff2f16 100644 --- a/service/character.py +++ b/service/character.py @@ -41,6 +41,7 @@ logger = logging.getLogger(__name__) class CharacterImportThread(threading.Thread): def __init__(self, paths, callback): threading.Thread.__init__(self) + self.name = "CharacterImport" self.paths = paths self.callback = callback @@ -96,6 +97,7 @@ class CharacterImportThread(threading.Thread): class SkillBackupThread(threading.Thread): def __init__(self, path, saveFmt, activeFit, callback): threading.Thread.__init__(self) + self.name = "SkillBackup" self.path = path self.saveFmt = saveFmt self.activeFit = activeFit diff --git a/service/fit.py b/service/fit.py index 7382df1fd..655c833e0 100644 --- a/service/fit.py +++ b/service/fit.py @@ -43,6 +43,7 @@ logger = logging.getLogger(__name__) class FitBackupThread(threading.Thread): def __init__(self, path, callback): threading.Thread.__init__(self) + self.name = "FitBackup" self.path = path self.callback = callback @@ -62,6 +63,7 @@ class FitBackupThread(threading.Thread): class FitImportThread(threading.Thread): def __init__(self, paths, callback): threading.Thread.__init__(self) + self.name = "FitImport" self.paths = paths self.callback = callback diff --git a/service/market.py b/service/market.py index c851957e3..dde6e9621 100644 --- a/service/market.py +++ b/service/market.py @@ -43,6 +43,10 @@ logger = logging.getLogger(__name__) mktRdy = threading.Event() class ShipBrowserWorkerThread(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + self.name = "ShipBrowser" + def run(self): self.queue = Queue.Queue() self.cache = {} @@ -73,6 +77,10 @@ class ShipBrowserWorkerThread(threading.Thread): pass class PriceWorkerThread(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + self.name = "PriceWorker" + def run(self): self.queue = Queue.Queue() self.wait = {} @@ -107,6 +115,10 @@ class PriceWorkerThread(threading.Thread): self.wait[itemID].append(callback) class SearchWorkerThread(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + self.name = "SearchWorker" + def run(self): self.cv = threading.Condition() self.searchRequest = None diff --git a/service/prefetch.py b/service/prefetch.py index 6c45ffc63..98ac622b3 100644 --- a/service/prefetch.py +++ b/service/prefetch.py @@ -30,6 +30,10 @@ logger = logging.getLogger(__name__) class PrefetchThread(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + self.name = "Prefetch" + def run(self): # We're a daemon thread, as such, interpreter might get shut down while we do stuff # Make sure we don't throw tracebacks to console @@ -40,6 +44,7 @@ class PrefetchThread(threading.Thread): prefetch = PrefetchThread() prefetch.daemon = True + prefetch.start() ######## diff --git a/service/update.py b/service/update.py index 47a3e35b0..9025a6583 100644 --- a/service/update.py +++ b/service/update.py @@ -29,6 +29,7 @@ import calendar class CheckUpdateThread(threading.Thread): def __init__(self, callback): threading.Thread.__init__(self) + self.name = "CheckUpdate" self.callback = callback self.settings = service.settings.UpdateSettings.getInstance() self.network = service.Network.getInstance() From 6049c9837c8b8966119f84069c18f3df33cc8c1b Mon Sep 17 00:00:00 2001 From: blitzman Date: Sat, 28 Jan 2017 23:35:42 -0500 Subject: [PATCH 5/5] Remove prefetch thread (unneeded and consumes resources?) --- service/prefetch.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/service/prefetch.py b/service/prefetch.py index 98ac622b3..a3efb38e2 100644 --- a/service/prefetch.py +++ b/service/prefetch.py @@ -28,25 +28,6 @@ import logging logger = logging.getLogger(__name__) - -class PrefetchThread(threading.Thread): - def __init__(self): - threading.Thread.__init__(self) - self.name = "Prefetch" - - def run(self): - # We're a daemon thread, as such, interpreter might get shut down while we do stuff - # Make sure we don't throw tracebacks to console - try: - eos.types.Character.setSkillList(eos.db.getItemsByCategory("Skill", eager=("effects", "attributes", "attributes.info.icon", "attributes.info.unit", "icon"))) - except: - pass - -prefetch = PrefetchThread() -prefetch.daemon = True - -prefetch.start() - ######## # The following code does not belong here, however until we rebuild skeletons # to include modified pyfa.py, this is the best place to put it. See GH issue