Start conversion of various wait dialogs to wx.ProgresDialog. Implemented new wx.ProgresDialog for fitting backup
This commit is contained in:
@@ -47,12 +47,11 @@ class FitBackupThread(threading.Thread):
|
||||
path = self.path
|
||||
sFit = Fit.getInstance()
|
||||
allFits = map(lambda x: x[0], sFit.getAllFits())
|
||||
backedUpFits = sFit.exportXml(*allFits)
|
||||
backedUpFits = sFit.exportXml(self.callback, *allFits)
|
||||
backupFile = open(path, "w", encoding="utf-8")
|
||||
backupFile.write(backedUpFits)
|
||||
backupFile.close()
|
||||
wx.CallAfter(self.callback)
|
||||
|
||||
wx.CallAfter(self.callback, -1)
|
||||
|
||||
class FitImportThread(threading.Thread):
|
||||
def __init__(self, paths, callback):
|
||||
@@ -127,6 +126,9 @@ class Fit(object):
|
||||
|
||||
return names
|
||||
|
||||
def countAllFits(self):
|
||||
return eos.db.countAllFits()
|
||||
|
||||
def countFitsWithShip(self, shipID):
|
||||
count = eos.db.countFitsWithShip(shipID)
|
||||
return count
|
||||
@@ -758,9 +760,9 @@ class Fit(object):
|
||||
fit = eos.db.getFit(fitID)
|
||||
return Port.exportDna(fit)
|
||||
|
||||
def exportXml(self, *fitIDs):
|
||||
def exportXml(self, callback = None, *fitIDs):
|
||||
fits = map(lambda fitID: eos.db.getFit(fitID), fitIDs)
|
||||
return Port.exportXml(*fits)
|
||||
return Port.exportXml(callback, *fits)
|
||||
|
||||
def backupFits(self, path, callback):
|
||||
thread = FitBackupThread(path, callback)
|
||||
|
||||
@@ -23,6 +23,7 @@ import json
|
||||
|
||||
from eos.types import State, Slot, Module, Cargo, Fit, Ship, Drone, Implant, Booster
|
||||
import service
|
||||
import wx
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
@@ -503,11 +504,11 @@ class Port(object):
|
||||
return dna + "::"
|
||||
|
||||
@classmethod
|
||||
def exportXml(cls, *fits):
|
||||
def exportXml(cls, callback=None, *fits):
|
||||
doc = xml.dom.minidom.Document()
|
||||
fittings = doc.createElement("fittings")
|
||||
doc.appendChild(fittings)
|
||||
for fit in fits:
|
||||
for i, fit in enumerate(fits):
|
||||
try:
|
||||
fitting = doc.createElement("fitting")
|
||||
fitting.setAttribute("name", fit.name)
|
||||
@@ -571,5 +572,8 @@ class Port(object):
|
||||
except:
|
||||
print "Failed on fitID: %d"%fit.ID
|
||||
continue
|
||||
finally:
|
||||
if callback:
|
||||
wx.CallAfter(callback, i)
|
||||
|
||||
return doc.toprettyxml()
|
||||
|
||||
Reference in New Issue
Block a user