Enable logging for account imports, also fix the character drop bug

This commit is contained in:
2011-01-11 13:38:39 +00:00
parent f34bc46bf9
commit ae57262317

View File

@@ -1,5 +1,6 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from xml.dom import minidom from xml.dom import minidom
import logging
from celery.decorators import task from celery.decorators import task
from celery.task.sets import TaskSet from celery.task.sets import TaskSet
@@ -42,17 +43,31 @@ def import_apikey(api_userid, api_key, user=None, force_cache=False):
""" """
Imports a EVE Account from the API, doesn't return a result Imports a EVE Account from the API, doesn't return a result
""" """
import_apikey_func(api_userid, api_key, user, force_cache) log = import_apikey.get_logger()
try:
import_apikey_func(api_userid, api_key, user, force_cache, log)
except:
log.error('Error importing API Key')
@task() @task()
def import_apikey_result(api_userid, api_key, user=None, force_cache=False): def import_apikey_result(api_userid, api_key, user=None, force_cache=False, callback=None):
""" """
Imports a EVE Account from the API and returns the account object when completed Imports a EVE Account from the API and returns the account object when completed
""" """
return import_apikey_func(api_userid, api_key, user, force_cache)
def import_apikey_func(api_userid, api_key, user=None, force_cache=False): log = import_apikey_result.get_logger()
log = import_apikey.get_logger('import_apikey_result') try:
results = import_apikey_func(api_userid, api_key, user, force_cache, log)
except APIAccessException, exc:
log.error('Error importing API Key - flagging for retry')
else:
if callback:
subtask(callback).delay(account=results)
else:
return results
def import_apikey_func(api_userid, api_key, user=None, force_cache=False, log=logging.getLogger(__name__)):
log.info('Importing %s/%s' % (api_userid, api_key)) log.info('Importing %s/%s' % (api_userid, api_key))
auth_params = {'userid': api_userid, 'apikey': api_key} auth_params = {'userid': api_userid, 'apikey': api_key}
@@ -111,7 +126,7 @@ def import_apikey_func(api_userid, api_key, user=None, force_cache=False):
# Process the account's character list # Process the account's character list
charlist = set(account.characters.all().values_list('id', flat=True)) charlist = set(account.characters.all().values_list('id', flat=True))
newcharlist = [char['characterID'] for char in doc['result']['characters']] newcharlist = [int(char['characterID']) for char in doc['result']['characters']]
log.info("[CHAR] Current %s, New: %s, Remove: %s" % (charlist, newcharlist, set(charlist - set(newcharlist)))) log.info("[CHAR] Current %s, New: %s, Remove: %s" % (charlist, newcharlist, set(charlist - set(newcharlist))))