Merge pull request #122 from kerel-fs/pr/fix121
commands/fetch_satellites: Replace BaseCommand.option_list with add_argumentspull/124/head
commit
95452b616f
|
@ -1,4 +1,3 @@
|
||||||
from optparse import make_option
|
|
||||||
from orbit import satellite
|
from orbit import satellite
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
@ -7,18 +6,25 @@ from db.base.models import Satellite
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
option_list = BaseCommand.option_list + (
|
|
||||||
make_option('--delete',
|
|
||||||
action='store_true',
|
|
||||||
dest='delete',
|
|
||||||
default=False,
|
|
||||||
help='Delete Satellite'),
|
|
||||||
)
|
|
||||||
args = '<Satellite Identifiers>'
|
|
||||||
help = 'Updates/Inserts Name for certain Satellites'
|
help = 'Updates/Inserts Name for certain Satellites'
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
# Positional arguments
|
||||||
|
parser.add_argument('satellite_identifiers',
|
||||||
|
nargs='+',
|
||||||
|
metavar='<Satellite Identifier>')
|
||||||
|
|
||||||
|
# Named (optional) arguments
|
||||||
|
parser.add_argument(
|
||||||
|
'--delete',
|
||||||
|
action='store_true',
|
||||||
|
dest='delete',
|
||||||
|
default=False,
|
||||||
|
help='Delete Satellite'
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
for item in args:
|
for item in options['satellite_identifiers']:
|
||||||
if options['delete']:
|
if options['delete']:
|
||||||
try:
|
try:
|
||||||
Satellite.objects.get(norad_cat_id=item).delete()
|
Satellite.objects.get(norad_cat_id=item).delete()
|
||||||
|
|
Loading…
Reference in New Issue