diff --git a/config.py b/config.py index eef59ef4a..8787ac6c9 100644 --- a/config.py +++ b/config.py @@ -11,4 +11,8 @@ else: 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 diff --git a/eos b/eos index 5741911f0..c73c25cc6 160000 --- a/eos +++ b/eos @@ -1 +1 @@ -Subproject commit 5741911f0f3270de748b46f09e76a3aa9e9452ae +Subproject commit c73c25cc6bce659adfdd216fd9ee83602a3e39e8 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/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/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 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/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) 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() 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): diff --git a/service/market.py b/service/market.py index f052a6597..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): @@ -229,19 +209,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 = [] @@ -254,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)