kopia lustrzana https://github.com/bristol-seds/pico-tracker
Habitat upload done. 'time_created' corresponds to the backlog time, gets sorted correctly by the habitat couchdb views
rodzic
3f11b52e8d
commit
6c67289f84
|
@ -10,23 +10,23 @@ from datetime import datetime
|
|||
couch = couchdb.Server('http://habitat.habhub.org/')
|
||||
db = couch['habitat']
|
||||
|
||||
"""
|
||||
Uploaded payload_telemetry to habhub
|
||||
"""
|
||||
def habitat_upload(rx_time, packet_string):
|
||||
|
||||
print packet_string
|
||||
|
||||
# Packet ID
|
||||
packet_base64 = base64.standard_b64encode(packet_string+"\n")
|
||||
packet_sha256 = hashlib.sha256(packet_base64).hexdigest()
|
||||
|
||||
# Time Created = backlog time
|
||||
time_created = rx_time.replace(microsecond=0).isoformat()+"+00:00"
|
||||
print time_created
|
||||
|
||||
# Time Uploaded = now
|
||||
now = datetime.utcnow()
|
||||
time_uploaded = now.replace(microsecond=0).isoformat()+"+00:00"
|
||||
|
||||
print db.save({
|
||||
return db.save({
|
||||
"type":"payload_telemetry",
|
||||
"_id": packet_sha256,
|
||||
"data":{
|
||||
|
@ -35,7 +35,7 @@ def habitat_upload(rx_time, packet_string):
|
|||
"receivers": {
|
||||
"BACKLOG": {
|
||||
"time_created": time_created,
|
||||
"time_uploaded": time_created,
|
||||
"time_uploaded": time_uploaded,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -140,6 +140,10 @@ with open(file_name, 'r') as data_file:
|
|||
print "%s: %s, %s" % ((str(datum['time']),) + datum['coords'][:2])
|
||||
|
||||
# Upload data to habitat
|
||||
datum = data[2]
|
||||
for datum in data[3:]:
|
||||
ukhas_str = ukhas_format(datum)
|
||||
habitat_upload(datum['time'], ukhas_str)
|
||||
try:
|
||||
print ukhas_str
|
||||
print habitat_upload(datum['time'], ukhas_str)
|
||||
except:
|
||||
None
|
||||
|
|
Ładowanie…
Reference in New Issue