mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Added better error logging and some documentation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
from datetime import datetime, timedelta
|
||||
from xml.dom import minidom
|
||||
import logging
|
||||
@@ -49,7 +50,7 @@ def import_apikey(api_userid, api_key, user=None, force_cache=False, **kwargs):
|
||||
try:
|
||||
import_apikey_func(api_userid, api_key, user, force_cache, log)
|
||||
except (APIAccessException, DocumentRetrievalError), exc:
|
||||
log.error('Error importing API Key - flagging for retry')
|
||||
log.error('Error importing API Key - flagging for retry', exc_info=sys.exc_info(), extra={'data': {'api_userid': api_userid, 'api_key': api_key}})
|
||||
import_apikey.retry(args=[api_userid, api_key, user, force_cache], exc=exc, kwargs=kwargs)
|
||||
|
||||
|
||||
@@ -63,7 +64,7 @@ def import_apikey_result(api_userid, api_key, user=None, force_cache=False, call
|
||||
try:
|
||||
results = import_apikey_func(api_userid, api_key, user, force_cache, log)
|
||||
except (APIAccessException, DocumentRetrievalError), exc:
|
||||
log.error('Error importing API Key - flagging for retry')
|
||||
log.error('Error importing API Key - flagging for retry', exc_info=sys.exc_info(), extra={'data': {'api_userid': api_userid, 'api_key': api_key}})
|
||||
import_apikey_result.retry(args=[api_userid, api_key, user, force_cache, callback], exc=exc, kwargs=kwargs)
|
||||
else:
|
||||
if callback:
|
||||
|
||||
@@ -73,12 +73,15 @@ def import_eve_character_func(character_id, api_key=None, user_id=None, logger=l
|
||||
|
||||
values = d['result']
|
||||
pchar, created = EVEPlayerCharacter.objects.get_or_create(id=character_id)
|
||||
|
||||
# Set the character's name, avoid oddities in the XML feed
|
||||
if not values['characterName'] == {}:
|
||||
pchar.name = values['characterName']
|
||||
else:
|
||||
pchar.name = ""
|
||||
pchar.security_status = values['securityStatus']
|
||||
|
||||
# Set corporation and join date
|
||||
corp, created = EVEPlayerCorporation.objects.get_or_create(id=values['corporationID'])
|
||||
from eve_api.tasks.corporation import import_corp_details
|
||||
if created or not corp.name or corp.api_last_updated < (datetime.utcnow() - timedelta(hours=12)):
|
||||
@@ -87,12 +90,14 @@ def import_eve_character_func(character_id, api_key=None, user_id=None, logger=l
|
||||
pchar.corporation = corp
|
||||
pchar.corporation_date = values['corporationDate']
|
||||
|
||||
# Derrive Race value from the choices
|
||||
for v in API_RACES_CHOICES:
|
||||
val, race = v
|
||||
if race == values['race']:
|
||||
pchar.race = val
|
||||
break
|
||||
|
||||
# If we have a valid API key, import the full character sheet
|
||||
if api_key and user_id:
|
||||
auth_params = {'userID': user_id, 'apiKey': api_key, 'characterID': character_id }
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user