From 2b4376614bf5c1bd13e1428512559b7336c78fa5 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 21 Sep 2010 16:40:44 +0200 Subject: [PATCH 1/7] Gray out unused toggles while browsing through the marketBrowser too --- gui/marketBrowser.py | 27 +++++++++++++++++---------- service/market.py | 10 +++++++--- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/gui/marketBrowser.py b/gui/marketBrowser.py index a2e1193bf..3f25c236f 100644 --- a/gui/marketBrowser.py +++ b/gui/marketBrowser.py @@ -179,7 +179,8 @@ class MarketBrowser(wx.Panel): cMarket = service.Market.getInstance() idNameMap = {} - for id, name, iconFile in cMarket.getVariations(self.marketView.GetPyData(root)): + data, usedMetas = cMarket.getVariations(self.marketView.GetPyData(root)) + for id, name, iconFile in data: iconId = self.addItemViewImage(iconFile) index = self.itemView.InsertImageStringItem(sys.maxint, name, iconId) idNameMap[id] = name @@ -193,6 +194,8 @@ class MarketBrowser(wx.Panel): if maxWidth > width: self.itemView.SetColumnWidth(0, maxWidth) + self.toggleButtons(usedMetas) + def toggleMetagroup(self, event): ctrl = wx.GetMouseState().ControlDown() cMarket = service.Market.getInstance() @@ -259,6 +262,18 @@ class MarketBrowser(wx.Panel): self.searchResults = results self.filteredSearchAdd() + def toggleButtons(self, usedMetas): + cMarket = service.Market.getInstance() + for name in ("normal", "faction", "complex", "officer"): + btn = getattr(self, name) + btn.SetValue(False) + btn.Enable(False) + + for meta in usedMetas: + btn = getattr(self, cMarket.getMetaName(meta)) + btn.SetValue(cMarket.isMetaIdActive(meta)) + btn.Enable(True) + def filteredSearchAdd(self): if self.searching is False: return @@ -281,15 +296,7 @@ class MarketBrowser(wx.Panel): self.itemView.SetItemData(index, id) #Gray out empty toggles - for name in ("normal", "faction", "complex", "officer"): - btn = getattr(self, name) - btn.SetValue(False) - btn.Enable(False) - - for meta in usedMetas: - btn = getattr(self, cMarket.getMetaName(meta)) - btn.SetValue(cMarket.isMetaIdActive(meta)) - btn.Enable(True) + self.toggleButtons(usedMetas) def sort(id1, id2): grp = cmp(idGroupMap[id1], idGroupMap[id2]) diff --git a/service/market.py b/service/market.py index f052a6597..c972b63ab 100644 --- a/service/market.py +++ b/service/market.py @@ -229,19 +229,23 @@ class Market(): mg = eos.db.getMarketGroup(marketGroupId) l = [] done = set() + populatedMetas = set() + for item in mg.items: + populatedMetas.add(1) if 1 in self.activeMetas: if item not in done: done.add(item) l.append((item.ID, item.name, item.icon.iconFile if item.icon else "")) - vars = eos.db.getVariations(item, metaGroups = tuple(self.activeMetas), eager="icon") + vars = eos.db.getVariations(item, eager=("icon", "metaGroup")) for var in vars: - if var not in done: + populatedMetas.add(var.metaGroup.ID) + if var not in done and var.metaGroup.ID in self.activeMetas: done.add(var) l.append((var.ID, var.name, var.icon.iconFile if var.icon else "")) - return l + return l, populatedMetas def getPrices(self, typeIDs, callback): requests = [] From bdd959d75fb9db5ce1d1c405da19ddc7db12dcdd Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 21 Sep 2010 20:54:30 +0200 Subject: [PATCH 2/7] Change over the price fetching code to a queue instead of a cv, fix some minor stuff --- gui/builtinStatsViews/priceViewFull.py | 4 ++-- service/market.py | 33 +++++--------------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/gui/builtinStatsViews/priceViewFull.py b/gui/builtinStatsViews/priceViewFull.py index 443edbc0f..cbe7ba277 100644 --- a/gui/builtinStatsViews/priceViewFull.py +++ b/gui/builtinStatsViews/priceViewFull.py @@ -36,7 +36,7 @@ class PriceViewFull(StatsView): self._timerRuns = 0 self._timerIdUpdate = wx.NewId() self._timerUpdate = None - + def OnTimer( self, event): if self._timerId == event.GetId(): if self._timerRuns >= self._timerRunsBeforeUpdate: @@ -81,7 +81,7 @@ class PriceViewFull(StatsView): hbox.Add(lbl, 0, wx.ALIGN_LEFT) hbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, " ISK"), 0, wx.ALIGN_LEFT) - self.labelEMStatus = wx.StaticText(contentPanel, wx.ID_ANY, "") + self.labelEMStatus = wx.StaticText(contentPanel, wx.ID_ANY, "") contentSizer.Add(self.labelEMStatus,0) def refreshPanel(self, fit): if fit is not None: diff --git a/service/market.py b/service/market.py index c972b63ab..3b50cd02a 100644 --- a/service/market.py +++ b/service/market.py @@ -23,48 +23,28 @@ import wx import collections import threading from sqlalchemy.orm.exc import NoResultFound +import Queue class PriceWorkerThread(threading.Thread): def run(self): - self.cv = threading.Condition() - self.updateRequests = collections.deque() - self.scheduled = set() + self.queue = Queue.Queue() self.processUpdates() def processUpdates(self): - updateRequests = self.updateRequests - cv = self.cv - + queue = self.queue while True: - cv.acquire() - - while len(updateRequests) == 0: - cv.wait() - # Grab our data and rerelease the lock - callback, requests = self.updateRequests.popleft() - self.scheduled.clear() - cv.release() + callback, requests = queue.get() # Grab prices, this is the time-consuming part if len(requests) > 0: eos.types.Price.fetchPrices(*requests) wx.CallAfter(callback) - + queue.task_done() def trigger(self, prices, callbacks): - self.cv.acquire() - self.updateRequests.append((callbacks, prices)) - self.scheduled.update(prices) - self.cv.notify() - self.cv.release() - - def isScheduled(self, price): - self.cv.acquire() - scheduled = price in self.scheduled - self.cv.release() - return scheduled + self.queue.put((callbacks, prices)) class SearchWorkerThread(threading.Thread): def run(self): @@ -258,7 +238,6 @@ class Market(): price = eos.types.Price(typeID) eos.db.saveddata_session.add(price) - requests.append(price) self.priceCache[typeID] = price requests.append(price) From a9d4ea7e24780549fbe6cb0bdab64e1616951ae2 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Tue, 21 Sep 2010 22:20:29 +0200 Subject: [PATCH 3/7] Enable saving on disk of saveddata. WARNING: This includes config changes, if you have custom config, be aware --- config.py | 4 ++++ run.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/config.py b/config.py index 3fd47dc1d..45f31e4c3 100644 --- a/config.py +++ b/config.py @@ -6,4 +6,8 @@ debug = False #Path autodetection, only change if it doesn't work path = os.path.dirname(unicode(__file__, sys.getfilesystemencoding())) homePath = os.path.expanduser(os.path.join("~", ".pyfa")) +saveddata = os.path.join(homePath, "saveddata.db") +# saveddata db location modifier, shouldn't ever need to touch this +import eos.config +eos.config.saveddata_connectionstring = "sqlite:///" + saveddata \ No newline at end of file diff --git a/run.py b/run.py index bc7ea5a57..357e33b88 100644 --- a/run.py +++ b/run.py @@ -20,8 +20,15 @@ from gui.mainFrame import MainFrame import wx +import config +import os.path +import eos.db if __name__ == "__main__": + #Make sure the saveddata db exists + if not os.path.exists(config.saveddata): + eos.db.saveddata_meta.create_all() + pyfa = wx.App(False) MainFrame() pyfa.MainLoop() From 6b851dd3e0e5797c1fd1d90202ceddfafd8076af Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Wed, 22 Sep 2010 10:32:26 +0200 Subject: [PATCH 4/7] Remove print statements --- gui/boosterView.py | 1 - gui/shipBrowser.py | 1 - 2 files changed, 2 deletions(-) diff --git a/gui/boosterView.py b/gui/boosterView.py index c19542d7c..33b555f96 100644 --- a/gui/boosterView.py +++ b/gui/boosterView.py @@ -46,7 +46,6 @@ class BoosterView(d.Display): cFit = service.Fit.getInstance() fitID = self.mainFrame.getActiveFit() trigger = cFit.addBooster(fitID, event.itemID) - print event.itemID if trigger: wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID)) diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 54138f7ef..4f0da17f0 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -182,7 +182,6 @@ class ShipBrowser(wx.Panel): wx.PostEvent(self.mainFrame, FitCreated(fitID=fitID)) def renameFit(self, event): - print "r" tree = self.getActiveTree() root = tree.GetSelection() type, _ = tree.GetPyData(root) From 0e20da2262f6434c1d1cb4d8e508a9898c1cd2e1 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Wed, 22 Sep 2010 10:34:00 +0200 Subject: [PATCH 5/7] Remove old toolbar file --- gui/mainToolBar.py | 66 ---------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 gui/mainToolBar.py diff --git a/gui/mainToolBar.py b/gui/mainToolBar.py deleted file mode 100644 index 1df4f251d..000000000 --- a/gui/mainToolBar.py +++ /dev/null @@ -1,66 +0,0 @@ -#=============================================================================== -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -#=============================================================================== - -import wx -from gui import bitmapLoader -import gui.mainFrame - -class MainToolBar(wx.ToolBar): - def __init__(self, parent): - style = wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT - wx.ToolBar.__init__(self, parent, wx.ID_ANY, style=style) - - self.AddLabelTool(10, "Ship Browser", bitmapLoader.getBitmap("ship_big", "icons"), shortHelp="Activate Ship Browser") - self.AddCheckLabelTool(20, "Character Editor", bitmapLoader.getBitmap("character_big", "icons"), shortHelp="Character editor") - - self.Bind(wx.EVT_TOOL, self.toggleShipBrowser, id=10) - self.Bind(wx.EVT_TOOL, self.toggleCharacterBrowser, id=20) - self.Realize() - self.shipBrowserState = False - gui.mainFrame.MainFrame.getInstance().shipBrowser.Hide() - - def toggleShipBrowser(self, event): - self.shipBrowserState = not self.shipBrowserState - state = self.shipBrowserState - mainFrame = gui.mainFrame.MainFrame.getInstance() - menuBar = mainFrame.GetMenuBar() - - if self.shipBrowserState: - self.SetToolNormalBitmap(10, bitmapLoader.getBitmap("market_big", "icons")) - self.SetToolShortHelp(10, "Activate Market Browser") - mainFrame.shipBrowser.build() - mainFrame.marketShipBrowserSizer.Replace(mainFrame.marketBrowser, mainFrame.shipBrowser) - else: - self.SetToolNormalBitmap(10, bitmapLoader.getBitmap("ship_big", "icons")) - self.SetToolShortHelp(10, "Activate Ship Browser") - mainFrame.marketShipBrowserSizer.Replace(mainFrame.shipBrowser, mainFrame.marketBrowser) - - menuBar.shipBrowserItem.Enable(not state) - menuBar.marketBrowserItem.Enable(state) - - mainFrame.shipBrowser.Show(state) - mainFrame.marketBrowser.Show(not state) - - mainFrame.marketShipBrowserSizer.Layout() - - - - - def toggleCharacterBrowser(self, event): - print event From 5d7461c54776164b210d2333a63d9ab2ce001a58 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Wed, 22 Sep 2010 11:10:16 +0200 Subject: [PATCH 6/7] Use latest eos version to grab performance improvement --- eos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eos b/eos index 5741911f0..c73c25cc6 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit 5741911f0f3270de748b46f09e76a3aa9e9452ae +Subproject commit c73c25cc6bce659adfdd216fd9ee83602a3e39e8 From eff289039a0eb5af8b3082fdda92dfb309953ed2 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Wed, 22 Sep 2010 11:21:19 +0200 Subject: [PATCH 7/7] Make sure to calculate freshly loaded fits, don't assume they're empty --- service/fit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/service/fit.py b/service/fit.py index 2fd32ae0d..5870169e0 100644 --- a/service/fit.py +++ b/service/fit.py @@ -70,6 +70,7 @@ class Fit(object): fit = eos.db.getFit(fitID) fit.fill() eos.db.commit() + fit.calculateModifiedAttributes() return fit def addImplant(self, fitID, itemID):