Add satellite field for following norad id TLE
parent
46d5533066
commit
72684ffcb9
|
@ -10,16 +10,19 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
satellites = Satellite.objects.exclude(manual_tle=True)
|
||||
satellites = Satellite.objects.exclude(manual_tle=True, norad_follow_id__isnull=True)
|
||||
|
||||
self.stdout.write("==Fetching TLEs==")
|
||||
|
||||
for obj in satellites:
|
||||
norad_id = obj.norad_cat_id
|
||||
if (obj.manual_tle):
|
||||
norad_id = obj.norad_follow_id
|
||||
try:
|
||||
sat = satellite(obj.norad_cat_id)
|
||||
sat = satellite(norad_id)
|
||||
except IndexError:
|
||||
self.stdout.write(('{0} - {1}: TLE not found [error]')
|
||||
.format(obj.name, obj.norad_cat_id))
|
||||
.format(obj.name, norad_id))
|
||||
continue
|
||||
|
||||
# Get latest satellite TLE and check if it changed
|
||||
|
@ -31,9 +34,9 @@ class Command(BaseCommand):
|
|||
pass
|
||||
if latest_tle == tle[1]:
|
||||
self.stdout.write(('{0} - {1}: TLE already exists [defer]')
|
||||
.format(obj.name, obj.norad_cat_id))
|
||||
.format(obj.name, norad_id))
|
||||
continue
|
||||
|
||||
Tle.objects.create(tle0=tle[0], tle1=tle[1], tle2=tle[2], satellite=obj)
|
||||
self.stdout.write(('{0} - {1}: new TLE found [updated]')
|
||||
.format(obj.name, obj.norad_cat_id))
|
||||
.format(obj.name, norad_id))
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.11 on 2018-12-04 16:33
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0049_auto_20180915_1503'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='satellite',
|
||||
name='norad_follow_id',
|
||||
field=models.PositiveIntegerField(blank=True, null=True),
|
||||
),
|
||||
]
|
|
@ -255,6 +255,7 @@ class StationStatusLog(models.Model):
|
|||
class Satellite(models.Model):
|
||||
"""Model for SatNOGS satellites."""
|
||||
norad_cat_id = models.PositiveIntegerField()
|
||||
norad_follow_id = models.PositiveIntegerField(blank=True, null=True)
|
||||
name = models.CharField(max_length=45)
|
||||
names = models.TextField(blank=True)
|
||||
image = models.CharField(max_length=100, blank=True, null=True)
|
||||
|
|
|
@ -20,11 +20,14 @@ from network.celery import app
|
|||
@app.task(ignore_result=True)
|
||||
def update_all_tle():
|
||||
"""Task to update all satellite TLEs"""
|
||||
satellites = Satellite.objects.exclude(manual_tle=True)
|
||||
satellites = Satellite.objects.exclude(manual_tle=True, norad_follow_id__isnull=True)
|
||||
|
||||
for obj in satellites:
|
||||
norad_id = obj.norad_cat_id
|
||||
if (obj.manual_tle):
|
||||
norad_id = obj.norad_follow_id
|
||||
try:
|
||||
sat = satellite(obj.norad_cat_id)
|
||||
sat = satellite(norad_id)
|
||||
except IndexError:
|
||||
continue
|
||||
|
||||
|
|
Loading…
Reference in New Issue