1
0
Fork 0
satnogs-db/db/base/management/commands/fetch_satellites.py

22 lines
717 B
Python
Raw Normal View History

from django.core.management.base import BaseCommand
2015-05-05 02:21:01 -06:00
from db.base.tasks import update_satellite
2015-05-05 02:21:01 -06:00
class Command(BaseCommand):
help = 'Updates/Inserts Name for certain Satellites'
2015-05-05 02:21:01 -06:00
def add_arguments(self, parser):
# Positional arguments
parser.add_argument('norad_ids',
nargs='+',
metavar='<norad id>')
2015-05-05 02:21:01 -06:00
def handle(self, *args, **options):
for norad_id in options['norad_ids']:
2015-05-05 02:21:01 -06:00
try:
update_satellite(int(norad_id), update_name=True, update_tle=False)
except LookupError:
self.stderr.write('Satellite {} not found in Celestrak'.format(norad_id))
continue