1
0
Fork 0

Handle all TLE exceptions

pull/194/head
Nikos Roussos 2016-01-26 15:52:06 +02:00
parent d60725e92f
commit b0522d3b47
2 changed files with 11 additions and 5 deletions

View File

@ -26,12 +26,12 @@ class Command(BaseCommand):
# Get latest satellite TLE and check if it changed
tle = sat.tle()
try:
latest_tle = obj.latest_tle
if latest_tle.tle1 == tle[1]:
latest_tle = obj.latest_tle.tle1
if latest_tle == tle[1]:
self.stdout.write(('Satellite {} with Identifier {} '
'found [defer]').format(obj.name, obj.norad_cat_id))
continue
except Tle.DoesNotExist:
except:
pass
Tle.objects.create(tle0=tle[0], tle1=tle[1], tle2=tle[2], satellite=obj)

View File

@ -175,9 +175,15 @@ def prediction_windows(request, sat_id, start_date, end_date):
}
return JsonResponse(data, safe=False)
satellite = ephem.readtle(str(sat.latest_tle.tle0),
str(sat.latest_tle.tle1),
try:
satellite = ephem.readtle(str(sat.latest_tle.tle0),
str(sat.latest_tle.tle1),
str(sat.latest_tle.tle2))
except:
data = {
'error': 'No TLEs for this satellite yet.'
}
return JsonResponse(data, safe=False)
end_date = datetime.strptime(end_date, '%Y-%m-%d %H:%M')