1
0
Fork 0

Simplify delete Satellite option

merge-requests/57/head
Nikos Roussos 2014-10-21 11:27:39 +03:00
parent fca8e4e5e0
commit 3be6f060d0
1 changed files with 13 additions and 11 deletions

View File

@ -1,6 +1,8 @@
from django.core.management.base import BaseCommand, CommandError
from optparse import make_option
from orbit import satellite
from django.core.management.base import BaseCommand, CommandError
from base.models import Satellite
@ -10,26 +12,26 @@ class Command(BaseCommand):
action='store_true',
dest='delete',
default=False,
help='Delete poll instead of closing it'),
help='Delete Satellite'),
)
args = '<Satellite Identifier|Range>'
args = '<Satellite Identifiers>'
help = 'Updates/Inserts TLEs for certain Satellites'
def handle(self, *args, **options):
for item in args:
if options['delete']:
try:
Satellite.objects.get(norad_cat_id=item).delete()
self.stdout.write('Satellite {}: deleted'.format(item))
continue
except:
raise CommandError('Satellite with Identifier {} does not exist'.format(item))
try:
sat = satellite(item)
except:
raise CommandError('Satellite with Identifier {} does not exist'.format(item))
if options['delete']:
try:
Satellite.objects.get(norad_cat_id=item).delete()
self.stdout.write('Satellite {}: {} deleted'.format(item, sat.name()))
continue
except:
raise CommandError('Satellite with Identifier {} does not exist'.format(item))
try:
obj = Satellite.objects.get(norad_cat_id=item)
except: