Add API caching, move calls out into its own modules for reuse.

This commit is contained in:
2013-11-11 20:50:16 +00:00
parent ccf41cc2ce
commit 79d12ee1c0
6 changed files with 88 additions and 24 deletions

View File

@@ -1,27 +1,8 @@
from django.core.management.base import BaseCommand
from django.db import transaction
from evesde.models.locations import Station
from eveapi import EVEAPIConnection
from evesde.eveapi.eve import import_conquerable_stations
class Command(BaseCommand):
help = 'Imports outposts from the EVE API.'
def handle(self, *args, **options):
api = EVEAPIConnection()
stations = Station.objects.all()
objs = []
for station in api.eve.ConquerableStationList().outposts:
print "Importing %s" % station.stationName
try:
obj = stations.get(pk=station.stationID)
except Station.DoesNotExist:
obj = Station(pk=station.stationID)
obj.name = station.stationName
obj.system_id = station.solarSystemID
objs.append(obj)
with transaction.atomic():
for obj in objs:
obj.save()
import_conquerable_stations()