Improvements to Character API

This commit adds default character and characters retrieved from API to
the DB, opening the door for "quick update" of API data (we now have api
details and character to update).
This commit is contained in:
blitzmann
2013-08-06 13:01:30 -04:00
parent 96bb1b197e
commit 7dce615933
3 changed files with 62 additions and 41 deletions

View File

@@ -24,7 +24,7 @@ import service
import itertools
from eos import eveapi
import config
import json
import os.path
import locale
import threading
@@ -228,19 +228,26 @@ class Character(object):
def getApiDetails(self, charID):
char = eos.db.getCharacter(charID)
return (char.apiID or "", char.apiKey or "")
if char.chars is not None:
chars = json.loads(char.chars)
else:
chars = None
return (char.apiID or "", char.apiKey or "", char.defaultChar or "", chars or [])
def charList(self, charID, userID, apiKey):
char = eos.db.getCharacter(charID)
try:
char.apiID = userID
char.apiKey = apiKey
return char.apiCharList(proxy = service.settings.ProxySettings.getInstance().getProxySettings())
charList = char.apiCharList(proxy = service.settings.ProxySettings.getInstance().getProxySettings())
char.chars = json.dumps(charList)
return charList
except:
return None
def apiFetch(self, charID, charName):
char = eos.db.getCharacter(charID)
char.defaultChar = charName
char.apiFetch(charName, proxy = service.settings.ProxySettings.getInstance().getProxySettings())
eos.db.commit()