mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Better API handling, avoid hitting the character API with NPC corps
This commit is contained in:
@@ -20,5 +20,8 @@ class APIAccessException(Exception):
|
||||
Raised on Access errors of any kind, network and EVE API failures
|
||||
"""
|
||||
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
|
||||
def __str__(self):
|
||||
return "An error was encountered while accessing the EVE API."
|
||||
return "An error was encountered while accessing the EVE API: %s" % self.msg
|
||||
|
||||
@@ -65,7 +65,7 @@ def import_eve_character_func(character_id, key_id=None, logger=logging.getLogge
|
||||
char_doc = CachedDocument.objects.api_query('/eve/CharacterInfo.xml.aspx', params={'characterID': character_id}, no_cache=False)
|
||||
except DocumentRetrievalError, exc:
|
||||
logger.error('Error retrieving CharacterInfo.xml.aspx for Character ID %s - %s' % (character_id, exc))
|
||||
raise APIAccessException
|
||||
raise APIAccessException(exc.value)
|
||||
|
||||
d = basic_xml_parse_doc(char_doc)['eveapi']
|
||||
if 'error' in d:
|
||||
|
||||
@@ -98,7 +98,8 @@ def import_corp_details_func(corp_id, log=logging.getLogger(__name__)):
|
||||
if int(d['allianceID']):
|
||||
corpobj.alliance, created = EVEPlayerAlliance.objects.get_or_create(id=d['allianceID'])
|
||||
|
||||
if int(d['ceoID']) > 1:
|
||||
# Skip looking up the CEOs for NPC corps and ones with no CEO defined (dead corps)
|
||||
if corp_id > 1000182 int(d['ceoID']) > 1:
|
||||
import_eve_character.delay(d['ceoID'], callback=link_ceo.subtask(corporation=corpobj.id))
|
||||
else:
|
||||
corpobj.ceo_character = None
|
||||
|
||||
Reference in New Issue
Block a user