Make it run again
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
from service.market import Market
|
||||
from service.fit import Fit
|
||||
from service.attribute import Attribute
|
||||
from service.character import Character
|
||||
from service.damagePattern import DamagePattern
|
||||
from service.targetResists import TargetResists
|
||||
from service.settings import SettingsProvider
|
||||
from service.fleet import Fleet
|
||||
from service.update import Update
|
||||
from service.price import Price
|
||||
from service.network import Network
|
||||
from service.eveapi import EVEAPIConnection, ParseXML
|
||||
from service.implantSet import ImplantSets
|
||||
|
||||
import wx
|
||||
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
|
||||
from service.pycrest import EVE
|
||||
from service.server import StoppableHTTPServer, AuthHandler
|
||||
from service.crest import Crest
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
import copy
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
from codecs import open
|
||||
from xml.etree import ElementTree
|
||||
@@ -28,11 +29,10 @@ import gzip
|
||||
|
||||
import wx
|
||||
|
||||
import config
|
||||
import eos.db
|
||||
import eos.types
|
||||
import service
|
||||
import config
|
||||
import logging
|
||||
from service.eveapi import EVEAPIConnection, ParseXML
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -49,7 +49,7 @@ class CharacterImportThread(threading.Thread):
|
||||
try:
|
||||
# we try to parse api XML data first
|
||||
with open(path, mode='r') as charFile:
|
||||
sheet = service.ParseXML(charFile)
|
||||
sheet = ParseXML(charFile)
|
||||
char = sCharacter.new(sheet.name+" (imported)")
|
||||
sCharacter.apiUpdateCharSheet(char.ID, sheet.skills)
|
||||
except:
|
||||
@@ -87,8 +87,6 @@ class SkillBackupThread(threading.Thread):
|
||||
def run(self):
|
||||
path = self.path
|
||||
sCharacter = Character.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fit = sFit.getFit(self.activeFit)
|
||||
backupData = ""
|
||||
if self.saveFmt == "xml" or self.saveFmt == "emp":
|
||||
backupData = sCharacter.exportXml()
|
||||
@@ -284,7 +282,7 @@ class Character(object):
|
||||
char.apiID = userID
|
||||
char.apiKey = apiKey
|
||||
|
||||
api = service.EVEAPIConnection()
|
||||
api = EVEAPIConnection()
|
||||
auth = api.auth(keyID=userID, vCode=apiKey)
|
||||
apiResult = auth.account.Characters()
|
||||
charList = map(lambda c: unicode(c.name), apiResult.characters)
|
||||
@@ -296,7 +294,7 @@ class Character(object):
|
||||
dbChar = eos.db.getCharacter(charID)
|
||||
dbChar.defaultChar = charName
|
||||
|
||||
api = service.EVEAPIConnection()
|
||||
api = EVEAPIConnection()
|
||||
auth = api.auth(keyID=dbChar.apiID, vCode=dbChar.apiKey)
|
||||
apiResult = auth.account.Characters()
|
||||
charID = None
|
||||
|
||||
@@ -8,6 +8,7 @@ elsewhere (in which case can be accessed with packs[name])
|
||||
"""
|
||||
|
||||
import pkgutil
|
||||
import importlib
|
||||
|
||||
# init parent dict
|
||||
all = {}
|
||||
@@ -15,10 +16,9 @@ all = {}
|
||||
# init container to store the separate conversion packs in case we need them
|
||||
packs = {}
|
||||
|
||||
|
||||
prefix = __name__ + "."
|
||||
for importer, modname, ispkg in pkgutil.iter_modules(__path__, prefix):
|
||||
conversionPack = __import__(modname, fromlist="dummy")
|
||||
conversionPack = importlib.import_module(modname)
|
||||
all.update(conversionPack.CONVERSIONS)
|
||||
modname_tail = modname.rsplit('.', 1)[-1]
|
||||
packs[modname_tail] = conversionPack.CONVERSIONS
|
||||
|
||||
@@ -9,10 +9,10 @@ import time
|
||||
import eos.db
|
||||
from eos.enum import Enum
|
||||
from eos.types import CrestChar
|
||||
|
||||
import service
|
||||
|
||||
import gui.globalEvents as GE
|
||||
from service.settings import CRESTSettings
|
||||
from service.server import StoppableHTTPServer, AuthHandler
|
||||
from service.pycrest.eve import EVE
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -64,7 +64,7 @@ class Crest():
|
||||
characters still in the cache (if USER mode)
|
||||
"""
|
||||
|
||||
self.settings = service.settings.CRESTSettings.getInstance()
|
||||
self.settings = CRESTSettings.getInstance()
|
||||
self.scopes = ['characterFittingsRead', 'characterFittingsWrite']
|
||||
|
||||
# these will be set when needed
|
||||
@@ -73,7 +73,7 @@ class Crest():
|
||||
self.ssoTimer = None
|
||||
|
||||
# Base EVE connection that is copied to all characters
|
||||
self.eve = service.pycrest.EVE(
|
||||
self.eve = EVE(
|
||||
client_id=self.settings.get('clientID') if self.settings.get('mode') == CrestModes.USER else self.clientIDs.get(self.settings.get('server')),
|
||||
api_key=self.settings.get('clientSecret') if self.settings.get('mode') == CrestModes.USER else None,
|
||||
redirect_uri=self.clientCallback,
|
||||
@@ -161,7 +161,7 @@ class Crest():
|
||||
if self.httpd:
|
||||
self.stopServer()
|
||||
time.sleep(1) # we need this to ensure that the previous get_request finishes, and then the socket will close
|
||||
self.httpd = service.StoppableHTTPServer(('', 6461), service.AuthHandler)
|
||||
self.httpd = StoppableHTTPServer(('', 6461), AuthHandler)
|
||||
thread.start_new_thread(self.httpd.serve, (self.handleLogin,))
|
||||
|
||||
self.state = str(uuid.uuid4())
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
import copy
|
||||
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
import eos.db
|
||||
import eos.types
|
||||
|
||||
|
||||
class ImportError(Exception):
|
||||
pass
|
||||
|
||||
pass
|
||||
class DamagePattern():
|
||||
instance = None
|
||||
@classmethod
|
||||
|
||||
@@ -166,7 +166,7 @@ from xml.parsers import expat
|
||||
from time import strptime
|
||||
from calendar import timegm
|
||||
|
||||
import service
|
||||
from service.network import Network
|
||||
|
||||
proxy = None
|
||||
proxySSL = False
|
||||
@@ -395,7 +395,7 @@ class _RootContext(_Context):
|
||||
response = None
|
||||
|
||||
if response is None:
|
||||
network = service.Network.getInstance()
|
||||
network = Network.getInstance()
|
||||
|
||||
req = self._scheme+'://'+self._host+path
|
||||
|
||||
@@ -414,7 +414,7 @@ class _RootContext(_Context):
|
||||
# implementor is handling fallbacks...
|
||||
try:
|
||||
return _ParseXML(response, True, store and (lambda obj: cache.store(self._host, path, kw, response, obj)))
|
||||
except Error, e:
|
||||
except Error as e:
|
||||
response = retrieve_fallback(self._host, path, kw, reason=e)
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
@@ -27,16 +27,18 @@ from codecs import open
|
||||
import xml.parsers.expat
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
|
||||
from eos.types import State, Slot
|
||||
from eos.types import State, Slot, Module, Drone, Fighter
|
||||
from eos.types import Fit as FitType
|
||||
|
||||
from service.market import Market
|
||||
from service.damagePattern import DamagePattern
|
||||
from service.character import Character
|
||||
from eos.saveddata.character import Character as saveddata_Character
|
||||
from service.fleet import Fleet
|
||||
from service.settings import SettingsProvider
|
||||
from service.port import Port
|
||||
|
||||
# TODO: port this to port.py
|
||||
#from service.port import Port
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -90,7 +92,7 @@ class Fit(object):
|
||||
def __init__(self):
|
||||
self.pattern = DamagePattern.getInstance().getDamagePattern("Uniform")
|
||||
self.targetResists = None
|
||||
self.character = Character.getInstance().all5()
|
||||
self.character = saveddata_Character.getAll5()
|
||||
self.booster = False
|
||||
self.dirtyFitIDs = set()
|
||||
|
||||
@@ -107,7 +109,7 @@ class Fit(object):
|
||||
"showMarketShortcuts": False,
|
||||
"enableGaugeAnimation": True,
|
||||
"exportCharges": True,
|
||||
"openFitInNew":False
|
||||
"openFitInNew": False
|
||||
}
|
||||
|
||||
self.serviceFittingOptions = SettingsProvider.getInstance().getSettings(
|
||||
@@ -164,7 +166,7 @@ class Fit(object):
|
||||
ship = eos.types.Ship(eos.db.getItem(shipID))
|
||||
except ValueError:
|
||||
ship = eos.types.Citadel(eos.db.getItem(shipID))
|
||||
fit = eos.types.Fit(ship)
|
||||
fit = FitType(ship)
|
||||
fit.name = name if name is not None else "New %s" % fit.ship.item.name
|
||||
fit.damagePattern = self.pattern
|
||||
fit.targetResists = self.targetResists
|
||||
@@ -343,7 +345,7 @@ class Fit(object):
|
||||
thing = eos.db.getItem(thing,
|
||||
eager=("attributes", "group.category"))
|
||||
|
||||
if isinstance(thing, eos.types.Fit):
|
||||
if isinstance(thing, FitType):
|
||||
if thing in fit.projectedFits:
|
||||
return
|
||||
|
||||
@@ -414,7 +416,7 @@ class Fit(object):
|
||||
thing.state = self.__getProposedState(thing, click)
|
||||
if not thing.canHaveState(thing.state, fit):
|
||||
thing.state = State.OFFLINE
|
||||
elif isinstance(thing, eos.types.Fit):
|
||||
elif isinstance(thing, FitType):
|
||||
projectionInfo = thing.getProjectionInfo(fitID)
|
||||
if projectionInfo:
|
||||
projectionInfo.active = not projectionInfo.active
|
||||
@@ -559,7 +561,7 @@ class Fit(object):
|
||||
|
||||
# Gather modules and convert Cargo item to Module, silently return if not a module
|
||||
try:
|
||||
cargoP = eos.types.Module(cargo.item)
|
||||
cargoP = Module(cargo.item)
|
||||
cargoP.owner = fit
|
||||
if cargoP.isValidState(State.ACTIVE):
|
||||
cargoP.state = State.ACTIVE
|
||||
@@ -692,10 +694,10 @@ class Fit(object):
|
||||
break
|
||||
'''
|
||||
if fighter is None:
|
||||
fighter = eos.types.Fighter(item)
|
||||
fighter = Fighter(item)
|
||||
used = fit.getSlotsUsed(fighter.slot)
|
||||
total = fit.getNumSlots(fighter.slot)
|
||||
standardAttackActive = False;
|
||||
standardAttackActive = False
|
||||
for ability in fighter.abilities:
|
||||
if (ability.effect.isImplemented and ability.effect.handlerName == u'fighterabilityattackm'):
|
||||
# Activate "standard attack" if available
|
||||
@@ -704,7 +706,7 @@ class Fit(object):
|
||||
else:
|
||||
# Activate all other abilities (Neut, Web, etc) except propmods if no standard attack is active
|
||||
if (ability.effect.isImplemented
|
||||
and standardAttackActive == False
|
||||
and standardAttackActive is False
|
||||
and ability.effect.handlerName != u'fighterabilitymicrowarpdrive'
|
||||
and ability.effect.handlerName != u'fighterabilityevasivemaneuvers'):
|
||||
ability.active = True
|
||||
@@ -783,7 +785,7 @@ class Fit(object):
|
||||
d.amount = amount
|
||||
d.amountActive = amount if active else 0
|
||||
|
||||
newD = eos.types.Drone(d.item)
|
||||
newD = Drone(d.item)
|
||||
newD.amount = total - amount
|
||||
newD.amountActive = newD.amount if active else 0
|
||||
l.append(newD)
|
||||
@@ -958,6 +960,8 @@ class Fit(object):
|
||||
fit.damagePattern = dp
|
||||
self.recalc(fit)
|
||||
|
||||
# TODO: port this to port.py
|
||||
'''
|
||||
def exportFit(self, fitID):
|
||||
fit = eos.db.getFit(fitID)
|
||||
return Port.exportEft(fit)
|
||||
@@ -981,6 +985,7 @@ class Fit(object):
|
||||
def exportMultiBuy(self, fitID):
|
||||
fit = eos.db.getFit(fitID)
|
||||
return Port.exportMultiBuy(fit)
|
||||
'''
|
||||
|
||||
def backupFits(self, path, callback):
|
||||
thread = FitBackupThread(path, callback)
|
||||
@@ -1056,14 +1061,17 @@ class Fit(object):
|
||||
if codec_found is None:
|
||||
return False, "Proper codec could not be established for %s" % path
|
||||
|
||||
# TODO: port this to port.py
|
||||
'''
|
||||
try:
|
||||
_, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found)
|
||||
fits += fitsImport
|
||||
except xml.parsers.expat.ExpatError, e:
|
||||
except xml.parsers.expat.ExpatError:
|
||||
return False, "Malformed XML in %s" % path
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
logger.exception("Unknown exception processing: %s", path)
|
||||
return False, "Unknown Error while processing %s" % path
|
||||
'''
|
||||
|
||||
IDs = []
|
||||
numFits = len(fits)
|
||||
@@ -1083,6 +1091,8 @@ class Fit(object):
|
||||
|
||||
return True, fits
|
||||
|
||||
# TODO: port this to port.py
|
||||
'''
|
||||
def importFitFromBuffer(self, bufferStr, activeFit=None):
|
||||
_, fits = Port.importAuto(bufferStr, activeFit=activeFit)
|
||||
for fit in fits:
|
||||
@@ -1091,6 +1101,7 @@ class Fit(object):
|
||||
fit.targetResists = self.targetResists
|
||||
eos.db.save(fit)
|
||||
return fits
|
||||
'''
|
||||
|
||||
def checkStates(self, fit, base):
|
||||
changed = False
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import eos.db
|
||||
from eos.types import Fleet as Fleet_, Wing, Squad
|
||||
import copy
|
||||
import eos.db
|
||||
from eos.saveddata.fleet import Fleet as Fleet_
|
||||
from eos.saveddata.fleet import Fleet as Wing
|
||||
from eos.saveddata.fleet import Fleet as Squad
|
||||
|
||||
class Fleet(object):
|
||||
instance = None
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import copy
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
import copy
|
||||
import service.market
|
||||
from service.market import Market
|
||||
|
||||
class ImportError(Exception):
|
||||
pass
|
||||
@@ -75,9 +76,9 @@ class ImplantSets():
|
||||
|
||||
def saveChanges(self, s):
|
||||
eos.db.save(s)
|
||||
|
||||
|
||||
def importSets(self, text):
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt = Market.getInstance()
|
||||
lines = text.splitlines()
|
||||
newSets = []
|
||||
errors = 0
|
||||
@@ -117,9 +118,8 @@ class ImplantSets():
|
||||
raise ImportError("No patterns found for import")
|
||||
if errors > 0:
|
||||
raise ImportError("%d sets imported from clipboard; %d errors"%(lenImports, errors))
|
||||
|
||||
|
||||
def exportSets(self):
|
||||
patterns = self.getImplantSetList()
|
||||
patterns.sort(key=lambda p: p.name)
|
||||
return eos.types.ImplantSet.exportSets(*patterns)
|
||||
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
|
||||
import re
|
||||
import threading
|
||||
import wx
|
||||
|
||||
import logging
|
||||
import Queue
|
||||
|
||||
import wx
|
||||
from sqlalchemy.sql import or_
|
||||
|
||||
import config
|
||||
import eos.db
|
||||
import eos.types
|
||||
from sqlalchemy.sql import and_, or_
|
||||
from service.settings import SettingsProvider, NetworkSettings
|
||||
import service
|
||||
import service.conversions as conversions
|
||||
import logging
|
||||
from service import conversions
|
||||
from service.settings import SettingsProvider
|
||||
from service.price import Price
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
@@ -86,7 +86,7 @@ class PriceWorkerThread(threading.Thread):
|
||||
|
||||
# Grab prices, this is the time-consuming part
|
||||
if len(requests) > 0:
|
||||
service.Price.fetchPrices(requests)
|
||||
Price.fetchPrices(requests)
|
||||
|
||||
wx.CallAfter(callback)
|
||||
queue.task_done()
|
||||
@@ -766,7 +766,7 @@ class Market():
|
||||
def cb():
|
||||
try:
|
||||
callback(requests)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
pass
|
||||
eos.db.commit()
|
||||
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
from service.settings import NetworkSettings
|
||||
|
||||
import urllib2
|
||||
import urllib
|
||||
import config
|
||||
import socket
|
||||
|
||||
import config
|
||||
from service.settings import NetworkSettings
|
||||
|
||||
# network timeout, otherwise pyfa hangs for a long while if no internet connection
|
||||
timeout = 3
|
||||
socket.setdefaulttimeout(timeout)
|
||||
@@ -35,14 +37,13 @@ class RequestError(StandardError):
|
||||
pass
|
||||
|
||||
class AuthenticationError(StandardError):
|
||||
pass
|
||||
pass
|
||||
|
||||
class ServerError(StandardError):
|
||||
pass
|
||||
pass
|
||||
|
||||
class TimeoutError(StandardError):
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
class Network():
|
||||
# Request constants - every request must supply this, as it is checked if
|
||||
@@ -55,7 +56,7 @@ class Network():
|
||||
_instance = None
|
||||
@classmethod
|
||||
def getInstance(cls):
|
||||
if cls._instance == None:
|
||||
if cls._instance is None:
|
||||
cls._instance = Network()
|
||||
|
||||
return cls._instance
|
||||
@@ -101,14 +102,14 @@ class Network():
|
||||
request = urllib2.Request(url, headers=headers, data=urllib.urlencode(data) if data else None)
|
||||
try:
|
||||
return urllib2.urlopen(request)
|
||||
except urllib2.HTTPError, error:
|
||||
except urllib2.HTTPError as error:
|
||||
if error.code == 404:
|
||||
raise RequestError()
|
||||
elif error.code == 403:
|
||||
raise AuthenticationError()
|
||||
elif error.code >= 500:
|
||||
raise ServerError()
|
||||
except urllib2.URLError, error:
|
||||
except urllib2.URLError as error:
|
||||
if "timed out" in error.reason:
|
||||
raise TimeoutError()
|
||||
else:
|
||||
|
||||
@@ -20,15 +20,30 @@
|
||||
import re
|
||||
import os
|
||||
import xml.dom
|
||||
|
||||
from eos.types import State, Slot, Module, Cargo, Fit, Ship, Drone, Implant, Booster, Citadel
|
||||
import service
|
||||
import wx
|
||||
import logging
|
||||
import config
|
||||
import collections
|
||||
import json
|
||||
|
||||
import wx
|
||||
|
||||
from eos.types import State, Slot, Module, Cargo, Fit, Ship, Drone, Implant, Booster, Citadel
|
||||
from service.crest import Crest
|
||||
from service.market import Market
|
||||
|
||||
import wx
|
||||
|
||||
from eos.types import State, Slot, Module, Cargo, Ship, Drone, Implant, Booster, Citadel
|
||||
from service.crest import Crest
|
||||
from service.market import Market
|
||||
from service.fit import Fit
|
||||
|
||||
import wx
|
||||
|
||||
from eos.types import State, Slot, Module, Cargo, Ship, Drone, Implant, Booster, Citadel
|
||||
from service.crest import Crest
|
||||
from service.market import Market
|
||||
from service.fit import Fit
|
||||
|
||||
logger = logging.getLogger("pyfa.service.port")
|
||||
|
||||
try:
|
||||
@@ -57,8 +72,8 @@ class Port(object):
|
||||
|
||||
nested_dict = lambda: collections.defaultdict(nested_dict)
|
||||
fit = nested_dict()
|
||||
sCrest = service.Crest.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
sCrest = Crest.getInstance()
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
eve = sCrest.eve
|
||||
|
||||
@@ -69,7 +84,7 @@ class Port(object):
|
||||
fit['ship']['id'] = ofit.ship.item.ID
|
||||
fit['ship']['name'] = ''
|
||||
|
||||
fit['description'] = "<pyfa:%d />"%ofit.ID
|
||||
fit['description'] = "<pyfa:%d />" % ofit.ID
|
||||
fit['items'] = []
|
||||
|
||||
slotNum = {}
|
||||
@@ -86,7 +101,7 @@ class Port(object):
|
||||
slot = int(module.getModifiedItemAttr("subSystemSlot"))
|
||||
item['flag'] = slot
|
||||
else:
|
||||
if not slot in slotNum:
|
||||
if slot not in slotNum:
|
||||
slotNum[slot] = INV_FLAGS[slot]
|
||||
|
||||
item['flag'] = slotNum[slot]
|
||||
@@ -99,7 +114,7 @@ class Port(object):
|
||||
fit['items'].append(item)
|
||||
|
||||
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
if not module.chargeID in charges:
|
||||
if module.chargeID not in charges:
|
||||
charges[module.chargeID] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
charges[module.chargeID] += module.numCharges or 1
|
||||
@@ -168,7 +183,7 @@ class Port(object):
|
||||
@staticmethod
|
||||
def importCrest(str):
|
||||
fit = json.loads(str)
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt = Market.getInstance()
|
||||
|
||||
f = Fit()
|
||||
f.name = fit['name']
|
||||
@@ -216,7 +231,7 @@ class Port(object):
|
||||
continue
|
||||
|
||||
# Recalc to get slot numbers correct for T3 cruisers
|
||||
service.Fit.getInstance().recalc(f)
|
||||
Fit.getInstance().recalc(f)
|
||||
|
||||
for module in moduleList:
|
||||
if module.fits(f):
|
||||
@@ -226,7 +241,7 @@ class Port(object):
|
||||
|
||||
@staticmethod
|
||||
def importDna(string):
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt = Market.getInstance()
|
||||
|
||||
ids = map(int, re.findall(r'\d+', string))
|
||||
for id in ids:
|
||||
@@ -291,7 +306,7 @@ class Port(object):
|
||||
moduleList.append(m)
|
||||
|
||||
# Recalc to get slot numbers correct for T3 cruisers
|
||||
service.Fit.getInstance().recalc(f)
|
||||
Fit.getInstance().recalc(f)
|
||||
|
||||
for module in moduleList:
|
||||
if module.fits(f):
|
||||
@@ -304,7 +319,7 @@ class Port(object):
|
||||
|
||||
@staticmethod
|
||||
def importEft(eftString):
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt = Market.getInstance()
|
||||
offineSuffix = " /OFFLINE"
|
||||
|
||||
fit = Fit()
|
||||
@@ -371,12 +386,12 @@ class Port(object):
|
||||
|
||||
if item.category.name == "Drone":
|
||||
extraAmount = int(extraAmount) if extraAmount is not None else 1
|
||||
if not modName in droneMap:
|
||||
if modName not in droneMap:
|
||||
droneMap[modName] = 0
|
||||
droneMap[modName] += extraAmount
|
||||
if len(modExtra) == 2 and item.category.name != "Drone":
|
||||
extraAmount = int(extraAmount) if extraAmount is not None else 1
|
||||
if not modName in cargoMap:
|
||||
if modName not in cargoMap:
|
||||
cargoMap[modName] = 0
|
||||
cargoMap[modName] += extraAmount
|
||||
elif item.category.name == "Implant":
|
||||
@@ -415,13 +430,13 @@ class Port(object):
|
||||
moduleList.append(m)
|
||||
|
||||
# Recalc to get slot numbers correct for T3 cruisers
|
||||
service.Fit.getInstance().recalc(fit)
|
||||
Fit.getInstance().recalc(fit)
|
||||
|
||||
for m in moduleList:
|
||||
if m.fits(fit):
|
||||
m.owner = fit
|
||||
if not m.isValidState(m.state):
|
||||
print "Error: Module", m, "cannot have state", m.state
|
||||
print("Error: Module", m, "cannot have state", m.state)
|
||||
|
||||
fit.modules.append(m)
|
||||
|
||||
@@ -442,7 +457,7 @@ class Port(object):
|
||||
"""Handle import from EFT config store file"""
|
||||
|
||||
# Check if we have such ship in database, bail if we don't
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt = Market.getInstance()
|
||||
try:
|
||||
sMkt.getItem(shipname)
|
||||
except:
|
||||
@@ -596,7 +611,7 @@ class Port(object):
|
||||
moduleList.append(m)
|
||||
|
||||
# Recalc to get slot numbers correct for T3 cruisers
|
||||
service.Fit.getInstance().recalc(f)
|
||||
Fit.getInstance().recalc(f)
|
||||
|
||||
for module in moduleList:
|
||||
if module.fits(f):
|
||||
@@ -615,7 +630,7 @@ class Port(object):
|
||||
|
||||
@staticmethod
|
||||
def importXml(text, callback=None, encoding="utf-8"):
|
||||
sMkt = service.Market.getInstance()
|
||||
sMkt = Market.getInstance()
|
||||
|
||||
doc = xml.dom.minidom.parseString(text.encode(encoding))
|
||||
fittings = doc.getElementsByTagName("fittings").item(0)
|
||||
@@ -676,7 +691,7 @@ class Port(object):
|
||||
continue
|
||||
|
||||
# Recalc to get slot numbers correct for T3 cruisers
|
||||
service.Fit.getInstance().recalc(f)
|
||||
Fit.getInstance().recalc(f)
|
||||
|
||||
for module in moduleList:
|
||||
if module.fits(f):
|
||||
@@ -694,10 +709,10 @@ class Port(object):
|
||||
offineSuffix = " /OFFLINE"
|
||||
export = "[%s, %s]\n" % (fit.ship.item.name, fit.name)
|
||||
stuff = {}
|
||||
sFit = service.Fit.getInstance()
|
||||
sFit = Fit.getInstance()
|
||||
for module in fit.modules:
|
||||
slot = module.slot
|
||||
if not slot in stuff:
|
||||
if slot not in stuff:
|
||||
stuff[slot] = []
|
||||
curr = module.item.name if module.item else ("[Empty %s slot]" % Slot.getName(slot).capitalize() if slot is not None else "")
|
||||
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
@@ -776,12 +791,12 @@ class Port(object):
|
||||
if mod.slot == Slot.SUBSYSTEM:
|
||||
subsystems.append(mod)
|
||||
continue
|
||||
if not mod.itemID in mods:
|
||||
if mod.itemID not in mods:
|
||||
mods[mod.itemID] = 0
|
||||
mods[mod.itemID] += 1
|
||||
|
||||
if mod.charge:
|
||||
if not mod.chargeID in charges:
|
||||
if mod.chargeID not in charges:
|
||||
charges[mod.chargeID] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
charges[mod.chargeID] += mod.numCharges or 1
|
||||
@@ -792,13 +807,8 @@ class Port(object):
|
||||
for mod in mods:
|
||||
dna += ":{0};{1}".format(mod, mods[mod])
|
||||
|
||||
# drones are known to be in split stacks
|
||||
groupedDrones = OrderedDict()
|
||||
for drone in fit.drones:
|
||||
groupedDrones[drone.itemID] = groupedDrones.get(drone.itemID, 0) + drone.amount
|
||||
|
||||
for droneItemID in groupedDrones:
|
||||
dna += ":{0};{1}".format(droneItemID, groupedDrones[droneItemID])
|
||||
dna += ":{0};{1}".format(drone.itemID, drone.amount)
|
||||
|
||||
for cargo in fit.cargo:
|
||||
# DNA format is a simple/dumb format. As CCP uses the slot information of the item itself
|
||||
@@ -807,7 +817,7 @@ class Port(object):
|
||||
# as being "Fitted" to whatever slot they are for, and it causes an corruption error in the
|
||||
# client when trying to save the fit
|
||||
if cargo.item.category.name == "Charge":
|
||||
if not cargo.item.ID in charges:
|
||||
if cargo.item.ID not in charges:
|
||||
charges[cargo.item.ID] = 0
|
||||
charges[cargo.item.ID] += cargo.amount
|
||||
|
||||
@@ -821,7 +831,7 @@ class Port(object):
|
||||
doc = xml.dom.minidom.Document()
|
||||
fittings = doc.createElement("fittings")
|
||||
doc.appendChild(fittings)
|
||||
sFit = service.Fit.getInstance()
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
for i, fit in enumerate(fits):
|
||||
try:
|
||||
@@ -847,7 +857,7 @@ class Port(object):
|
||||
# Order of subsystem matters based on this attr. See GH issue #130
|
||||
slotId = module.getModifiedItemAttr("subSystemSlot") - 125
|
||||
else:
|
||||
if not slot in slotNum:
|
||||
if slot not in slotNum:
|
||||
slotNum[slot] = 0
|
||||
|
||||
slotId = slotNum[slot]
|
||||
@@ -861,7 +871,7 @@ class Port(object):
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
if not module.charge.name in charges:
|
||||
if module.charge.name not in charges:
|
||||
charges[module.charge.name] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
charges[module.charge.name] += module.numCharges or 1
|
||||
@@ -874,7 +884,7 @@ class Port(object):
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
for cargo in fit.cargo:
|
||||
if not cargo.item.name in charges:
|
||||
if cargo.item.name not in charges:
|
||||
charges[cargo.item.name] = 0
|
||||
charges[cargo.item.name] += cargo.amount
|
||||
|
||||
@@ -885,7 +895,7 @@ class Port(object):
|
||||
hardware.setAttribute("type", name)
|
||||
fitting.appendChild(hardware)
|
||||
except:
|
||||
print "Failed on fitID: %d"%fit.ID
|
||||
print("Failed on fitID: %d" % fit.ID)
|
||||
continue
|
||||
finally:
|
||||
if callback:
|
||||
@@ -897,13 +907,12 @@ class Port(object):
|
||||
def exportMultiBuy(fit):
|
||||
export = "%s\n" % (fit.ship.item.name)
|
||||
stuff = {}
|
||||
sFit = service.Fit.getInstance()
|
||||
sFit = Fit.getInstance()
|
||||
for module in fit.modules:
|
||||
slot = module.slot
|
||||
if not slot in stuff:
|
||||
if slot not in stuff:
|
||||
stuff[slot] = []
|
||||
curr = "%s\n" % module.item.name if module.item else (
|
||||
"")
|
||||
curr = "%s\n" % module.item.name if module.item else ""
|
||||
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
curr += "%s x%s\n" % (module.charge.name, module.numCharges)
|
||||
stuff[slot].append(curr)
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
#===============================================================================
|
||||
|
||||
import threading
|
||||
import config
|
||||
import os
|
||||
|
||||
import config
|
||||
import eos.types
|
||||
import eos.db.migration as migration
|
||||
from eos.db import migration
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
|
||||
class PrefetchThread(threading.Thread):
|
||||
@@ -44,27 +45,26 @@ prefetch.start()
|
||||
# @ todo: move this to pyfa.py
|
||||
########
|
||||
|
||||
#Make sure the saveddata db exists
|
||||
if not os.path.exists(config.savePath):
|
||||
# Make sure the saveddata db exists
|
||||
if config.savePath and not os.path.exists(config.savePath):
|
||||
os.mkdir(config.savePath)
|
||||
|
||||
if os.path.isfile(config.saveDB):
|
||||
if config.saveDB and os.path.isfile(config.saveDB):
|
||||
# If database exists, run migration after init'd database
|
||||
eos.db.saveddata_meta.create_all()
|
||||
migration.update(eos.db.saveddata_engine)
|
||||
# Import default database values
|
||||
# Import values that must exist otherwise Pyfa breaks
|
||||
DefaultDatabaseValues.importRequiredDefaults()
|
||||
else:
|
||||
elif config.saveDB:
|
||||
# If database does not exist, do not worry about migration. Simply
|
||||
# create and set version
|
||||
eos.db.saveddata_meta.create_all()
|
||||
eos.db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
|
||||
#Import default database values
|
||||
# Import default database values
|
||||
# Import values that must exist otherwise Pyfa breaks
|
||||
DefaultDatabaseValues.importRequiredDefaults()
|
||||
# Import default values for damage profiles
|
||||
DefaultDatabaseValues.importDamageProfileDefaults()
|
||||
# Import default values for target resist profiles
|
||||
DefaultDatabaseValues.importResistProfileDefaults()
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import service
|
||||
import eos.db
|
||||
import eos.types
|
||||
|
||||
import time
|
||||
from xml.dom import minidom
|
||||
|
||||
import eos
|
||||
from service.network import Network, TimeoutError
|
||||
|
||||
VALIDITY = 24*60*60 # Price validity period, 24 hours
|
||||
REREQUEST = 4*60*60 # Re-request delay for failed fetches, 4 hours
|
||||
TIMEOUT = 15*60 # Network timeout delay for connection issues, 15 minutes
|
||||
@@ -71,15 +72,15 @@ class Price():
|
||||
|
||||
# Attempt to send request and process it
|
||||
try:
|
||||
network = service.Network.getInstance()
|
||||
network = Network.getInstance()
|
||||
data = network.request(baseurl, network.PRICES, data)
|
||||
xml = minidom.parse(data)
|
||||
types = xml.getElementsByTagName("marketstat").item(0).getElementsByTagName("type")
|
||||
# Cycle through all types we've got from request
|
||||
for type in types:
|
||||
for type_ in types:
|
||||
# Get data out of each typeID details tree
|
||||
typeID = int(type.getAttribute("id"))
|
||||
sell = type.getElementsByTagName("sell").item(0)
|
||||
typeID = int(type_.getAttribute("id"))
|
||||
sell = type_.getElementsByTagName("sell").item(0)
|
||||
# If price data wasn't there, set price to zero
|
||||
try:
|
||||
percprice = float(sell.getElementsByTagName("percentile").item(0).firstChild.data)
|
||||
@@ -96,7 +97,7 @@ class Price():
|
||||
del priceMap[typeID]
|
||||
|
||||
# If getting or processing data returned any errors
|
||||
except service.network.TimeoutError, e:
|
||||
except TimeoutError:
|
||||
# Timeout error deserves special treatment
|
||||
for typeID in priceMap.keys():
|
||||
priceobj = priceMap[typeID]
|
||||
|
||||
@@ -9,5 +9,3 @@ logger = logging.getLogger('pycrest')
|
||||
logger.addHandler(NullHandler())
|
||||
|
||||
version = "0.0.1"
|
||||
|
||||
from .eve import EVE
|
||||
@@ -1,15 +1,17 @@
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
import base64
|
||||
import time
|
||||
import zlib
|
||||
|
||||
import requests
|
||||
|
||||
from . import version
|
||||
from compat import bytes_, text_
|
||||
from errors import APIException
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
||||
import config
|
||||
from service.pycrest.compat import bytes_, text_
|
||||
from service.pycrest.errors import APIException
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse, urlunparse, parse_qsl
|
||||
except ImportError: # pragma: no cover
|
||||
@@ -20,13 +22,6 @@ try:
|
||||
except ImportError: # pragma: no cover
|
||||
import cPickle as pickle
|
||||
|
||||
try:
|
||||
from urllib.parse import quote
|
||||
except ImportError: # pragma: no cover
|
||||
from urllib import quote
|
||||
import logging
|
||||
import re
|
||||
import config
|
||||
|
||||
logger = logging.getLogger("pycrest.eve")
|
||||
cache_re = re.compile(r'max-age=([0-9]+)')
|
||||
@@ -110,8 +105,7 @@ class APIConnection(object):
|
||||
"Accept": "application/json",
|
||||
})
|
||||
session.headers.update(additional_headers)
|
||||
session.mount('https://public-crest.eveonline.com',
|
||||
HTTPAdapter())
|
||||
session.mount('https://public-crest.eveonline.com', HTTPAdapter())
|
||||
self._session = session
|
||||
if cache:
|
||||
if isinstance(cache, APICache):
|
||||
|
||||
@@ -1,32 +1,23 @@
|
||||
import datetime
|
||||
import ssl
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
||||
try:
|
||||
from requests.packages import urllib3
|
||||
from requests.packages.urllib3.util import ssl_
|
||||
|
||||
from requests.packages.urllib3.exceptions import (
|
||||
SystemTimeWarning,
|
||||
SecurityWarning,
|
||||
)
|
||||
from requests.packages.urllib3.packages.ssl_match_hostname import \
|
||||
match_hostname
|
||||
from requests.packages import urllib3
|
||||
from requests.packages.urllib3.util import ssl_
|
||||
from requests.packages.urllib3.exceptions import (
|
||||
SystemTimeWarning,
|
||||
SecurityWarning,
|
||||
)
|
||||
from requests.packages.urllib3.packages.ssl_match_hostname import \
|
||||
match_hostname
|
||||
except:
|
||||
import urllib3
|
||||
from urllib3.util import ssl_
|
||||
|
||||
from urllib3.exceptions import (
|
||||
SystemTimeWarning,
|
||||
SecurityWarning,
|
||||
)
|
||||
from urllib3.packages.ssl_match_hostname import \
|
||||
match_hostname
|
||||
|
||||
|
||||
import urllib3
|
||||
from urllib3.util import ssl_
|
||||
from urllib3.exceptions import SystemTimeWarning, SecurityWarning
|
||||
from urllib3.packages.ssl_match_hostname import match_hostname
|
||||
|
||||
|
||||
class WeakCiphersHTTPSConnection(
|
||||
|
||||
@@ -2,11 +2,12 @@ import BaseHTTPServer
|
||||
import urlparse
|
||||
import socket
|
||||
import thread
|
||||
import wx
|
||||
from service.settings import CRESTSettings
|
||||
|
||||
import logging
|
||||
|
||||
import wx
|
||||
|
||||
from service.settings import CRESTSettings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
HTML = '''
|
||||
@@ -121,4 +122,3 @@ if __name__ == "__main__":
|
||||
thread.start_new_thread(httpd.serve, ())
|
||||
raw_input("Press <RETURN> to stop server\n")
|
||||
httpd.stop()
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
|
||||
import cPickle
|
||||
import os.path
|
||||
import config
|
||||
import urllib2
|
||||
|
||||
import config
|
||||
|
||||
class SettingsProvider():
|
||||
BASE_PATH = os.path.join(config.savePath, "settings")
|
||||
BASE_PATH = os.path.join(config.savePath or ".", "settings")
|
||||
settings = {}
|
||||
_instance = None
|
||||
@classmethod
|
||||
@@ -260,8 +261,8 @@ class HTMLExportSettings():
|
||||
|
||||
def setEnabled(self, enabled):
|
||||
self.serviceHTMLExportSettings["enabled"] = enabled
|
||||
|
||||
|
||||
|
||||
|
||||
def getMinimalEnabled(self):
|
||||
return self.serviceHTMLExportSettings["minimal"]
|
||||
|
||||
|
||||
@@ -17,14 +17,16 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
import copy
|
||||
|
||||
class ImportError(Exception):
|
||||
pass
|
||||
import eos
|
||||
from eos.saveddata import targetResists as db_targetResists
|
||||
|
||||
class TargetResists():
|
||||
|
||||
class ImportError(Exception):
|
||||
pass
|
||||
|
||||
class TargetResists(object):
|
||||
instance = None
|
||||
@classmethod
|
||||
def getInstance(cls):
|
||||
@@ -84,5 +86,4 @@ class TargetResists():
|
||||
def exportPatterns(self):
|
||||
patterns = self.getTargetResistsList()
|
||||
patterns.sort(key=lambda p: p.name)
|
||||
return eos.types.TargetResists.exportPatterns(*patterns)
|
||||
|
||||
return db_targetResists.TargetResists.exportPatterns(*patterns)
|
||||
|
||||
@@ -18,23 +18,25 @@
|
||||
#===============================================================================
|
||||
|
||||
import threading
|
||||
import wx
|
||||
import urllib2
|
||||
import json
|
||||
import config
|
||||
import service
|
||||
import dateutil.parser
|
||||
import calendar
|
||||
|
||||
import wx
|
||||
import dateutil.parser
|
||||
|
||||
import config
|
||||
from service.network import Network
|
||||
from service.settings import UpdateSettings
|
||||
|
||||
class CheckUpdateThread(threading.Thread):
|
||||
def __init__(self, callback):
|
||||
threading.Thread.__init__(self)
|
||||
self.callback = callback
|
||||
self.settings = service.settings.UpdateSettings.getInstance()
|
||||
self.network = service.Network.getInstance()
|
||||
self.settings = UpdateSettings.getInstance()
|
||||
self.network = Network.getInstance()
|
||||
|
||||
def run(self):
|
||||
network = service.Network.getInstance()
|
||||
network = Network.getInstance()
|
||||
|
||||
try:
|
||||
response = network.request('https://api.github.com/repos/pyfa-org/Pyfa/releases', network.UPDATE)
|
||||
@@ -91,5 +93,3 @@ class Update():
|
||||
if cls.instance == None:
|
||||
cls.instance = Update()
|
||||
return cls.instance
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user