mirror of
https://github.com/nikdoof/limetime.git
synced 2025-12-14 10:12:23 +00:00
Initial import of codebase
This commit is contained in:
0
app/timer/management/commands/__init__.py
Normal file
0
app/timer/management/commands/__init__.py
Normal file
23
app/timer/management/commands/import_alliances.py
Normal file
23
app/timer/management/commands/import_alliances.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import transaction
|
||||
from timer.models import Alliance, Corporation
|
||||
from eveapi import EVEAPIConnection
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = ''
|
||||
help = 'Updates alliances from the EVE API'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
api = EVEAPIConnection()
|
||||
|
||||
alliance_list = api.eve.AllianceList().alliances
|
||||
print 'Updating %d alliances... ' % len(alliance_list)
|
||||
with transaction.commit_on_success():
|
||||
for alliance in alliance_list:
|
||||
allobj, created = Alliance.objects.get_or_create(pk=alliance.allianceID)
|
||||
allobj.name = alliance.name
|
||||
allobj.save()
|
||||
corp_ids = [x.corporationID for x in alliance.memberCorporations]
|
||||
Corporation.objects.exclude(pk__in=corp_ids).update(alliance=None)
|
||||
Corporation.objects.filter(pk__in=corp_ids).update(alliance=allobj)
|
||||
print 'Done'
|
||||
44
app/timer/management/commands/import_map.py
Normal file
44
app/timer/management/commands/import_map.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from __future__ import division
|
||||
import sqlite3
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import transaction
|
||||
from timer.models import Region, Constellation, System, Planet, Moon
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = '<map csv>'
|
||||
help = 'Imports the EVE Map from a sqlite dump of the SDE table mapDenormalized'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
# Connect to the sqlite3 DB
|
||||
db = sqlite3.connect(args[0])
|
||||
cur = db.cursor()
|
||||
|
||||
objs = []
|
||||
|
||||
# eveUnits
|
||||
print "Importing mapDenormalize..."
|
||||
cur.execute("""SELECT itemID, typeID, groupID, solarSystemID, constellationID, regionID, orbitID, x, y, z, itemName FROM mapDenormalize WHERE typeID in (3, 4, 5, 14) OR groupID = 7""")
|
||||
for row in cur.fetchall():
|
||||
id, type, group, solarid, constellationid, regionid, orbitid, x, y, z, name = row
|
||||
|
||||
if int(type) == 3:
|
||||
objs.append(Region(pk=id, name=name, x=0, y=0, z=0))
|
||||
elif int(type) == 4:
|
||||
objs.append(Constellation(pk=id, name=name, region_id=regionid, x=0, y=0, z=0))
|
||||
elif int(type) == 5:
|
||||
objs.append(System(pk=id, name=name, constellation_id=constellationid, x=0, y=0, z=0))
|
||||
elif int(group) == 7:
|
||||
objs.append(Planet(pk=id, name=name, system_id=solarid, x=x, y=y, z=z))
|
||||
elif int(type) == 14:
|
||||
objs.append(Moon(pk=id, name=name, planet_id=orbitid, x=x, y=y, z=z))
|
||||
print "Done"
|
||||
# Dump to DB
|
||||
|
||||
print 'Processing %d objects for commiting...' % len(objs)
|
||||
with transaction.commit_on_success():
|
||||
for i, x in enumerate(objs, start=1):
|
||||
if i % 1000 == 0: print "%d/%d (%d%%)" % (i, len(objs), round(i/len(objs) * 100))
|
||||
x.save()
|
||||
print 'Commited'
|
||||
24
app/timer/management/commands/import_stations.py
Normal file
24
app/timer/management/commands/import_stations.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import transaction
|
||||
from timer.models import Station, System
|
||||
from eveapi import EVEAPIConnection
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = ''
|
||||
help = 'Updates conquerable stations from the EVE API'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
api = EVEAPIConnection()
|
||||
|
||||
station_list = api.eve.ConquerableStationList().outposts
|
||||
print 'Updating %d stations... ' % len(station_list)
|
||||
with transaction.commit_on_success():
|
||||
for station in station_list:
|
||||
try:
|
||||
obj = Station.objects.get(pk=station.stationID)
|
||||
except Station.DoesNotExist:
|
||||
obj = Station(pk=station.stationID)
|
||||
obj.system, created = System.objects.get_or_create(pk=station.solarSystemID)
|
||||
obj.name = station.stationName
|
||||
obj.save()
|
||||
print 'Done'
|
||||
Reference in New Issue
Block a user