Update remote with local emergancy fixes
parent
de4f6c0b9b
commit
7b1366ad37
30
satnogs.py
30
satnogs.py
|
@ -38,23 +38,29 @@ def getFuture():
|
|||
global Observations
|
||||
global TLEs
|
||||
global StationsPasses
|
||||
norads = {}
|
||||
TLEs = defaultdict(list)
|
||||
StationsPasses = defaultdict(list)
|
||||
observations = defaultdict(dict)
|
||||
Start = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
End = (datetime.utcnow() + timedelta(minutes=30))
|
||||
End = (datetime.utcnow() + timedelta(days = 1))
|
||||
End = End.strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
passes = get_paginated_endpoint("https://network.satnogs.org/api/jobs/")
|
||||
#obs = get_paginated_endpoint("https://network.satnogs.org/api/observations/?end="+end+"&format=json&start="+start)
|
||||
#for x in tqdm(obs):
|
||||
# observations[x["id"]] = x
|
||||
# print("Started")
|
||||
# obs = get_paginated_endpoint("https://network.satnogs.org/api/observations/?end="+End+"&format=json&start="+Start)
|
||||
# for x in obs:
|
||||
# norads[x["id"]] = x["noard_cat_id"]
|
||||
print("Ended")
|
||||
Observations = defaultdict(list)
|
||||
for x in passes:
|
||||
if x["ground_station"] == None:
|
||||
continue
|
||||
#if x["id"] in observations:
|
||||
#noard = norads[x["id"]]
|
||||
norad = int(x["tle1"].split(" ")[1].replace("U",""))
|
||||
try:
|
||||
if(not norad in SatDescrip.keys()):
|
||||
continue
|
||||
start = datetime.strptime(x["start"], '%Y-%m-%dT%H:%M:%Sz')
|
||||
start = start.replace(tzinfo=utc)
|
||||
|
||||
|
@ -62,9 +68,9 @@ def getFuture():
|
|||
end = end.replace(tzinfo=utc)
|
||||
# "transmitter":Transmitters[observations[x["id"]]["norad_cat_id"]][x["transmitter"]]
|
||||
if start < end:
|
||||
Observations[norad].append({"station": x["ground_station"], "transmitter": Transmitters[norad][x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
||||
Observations[norad].append({"station": x["ground_station"], "transmitter": Transmitters[x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
||||
TLEs[norad] = EarthSatellite(x["tle1"], x["tle2"],x["tle0"])
|
||||
StationsPasses[x["ground_station"]].append({"norad": norad, "transmitter": Transmitters[norad][x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
||||
StationsPasses[x["ground_station"]].append({"norad": norad, "transmitter": Transmitters[x["transmitter"]], "start": start, "end": end, "id": x["id"]})
|
||||
except Exception as e:
|
||||
pass
|
||||
print("Error on observation number: " + str(x["id"]) + " "+str(norad)+" " + str(e))
|
||||
|
@ -130,11 +136,11 @@ def updateTransmitters():
|
|||
print("Updating Transmitters")
|
||||
temp = requests.get("https://db.satnogs.org/api/transmitters/").json()
|
||||
for x in temp:
|
||||
Transmitters[x["norad_cat_id"]][x["uuid"]] = [x["description"], [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255]]
|
||||
Transmitters[x["uuid"]] = [x["description"], [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255]]
|
||||
SatDescrip[x["norad_cat_id"]] = ""
|
||||
for x in Transmitters.keys():
|
||||
for y in Transmitters[x].keys():
|
||||
SatDescrip[x] += '<div class="trans" style="background-color:#'+str("%02x" % Transmitters[x][y][1][0])+str("%02x" % Transmitters[x][y][1][1])+str("%02x" % Transmitters[x][y][1][2])+'";>'+Transmitters[x][y][0]+'</div>'
|
||||
#for x in Transmitters.keys():
|
||||
for x in temp:
|
||||
SatDescrip[x["norad_cat_id"]] += '<div class="trans" style="background-color:#'+str("%02x" % Transmitters[x["uuid"]][1][0])+str("%02x" % Transmitters[x["uuid"]][1][1])+str("%02x" % Transmitters[x["uuid"]][1][2])+'";>'+Transmitters[x["uuid"]][0]+'</div>'
|
||||
print("Finished Updating Transmitters")
|
||||
|
||||
@scheduler.scheduled_job('interval', minutes=15)#hours=1)
|
||||
|
@ -163,6 +169,7 @@ def updateStations():
|
|||
|
||||
#@scheduler.scheduled_job('interval', minutes=5)
|
||||
def updateCZML():
|
||||
#print(SatDescrip.keys())
|
||||
print("Updating CZML")
|
||||
global CZMLOnline
|
||||
global CZMLOffline
|
||||
|
@ -217,6 +224,7 @@ def updateCZML():
|
|||
sat["billboard"] = {"image": "static/sat.png", "scale": 0.50}
|
||||
sat["position"] = {}
|
||||
sat["position"]["cartographicDegrees"] = []
|
||||
# print(y)
|
||||
sat["description"] = SatDescrip[x]
|
||||
temp = y["start"]
|
||||
time = 0
|
||||
|
@ -379,4 +387,4 @@ updateTransmitters()
|
|||
getFuture()
|
||||
updateCZML()
|
||||
scheduler.start()
|
||||
app.run(use_reloader=False, host="0.0.0.0", port=8080)
|
||||
app.run(use_reloader=False, host="0.0.0.0", port=5000)
|
||||
|
|
Loading…
Reference in New Issue