Habitat upload done. 'time_created' corresponds to the backlog time, gets sorted correctly by the habitat couchdb views

master
Richard Meadows 2015-08-02 13:02:46 +01:00
rodzic 3f11b52e8d
commit 6c67289f84
2 zmienionych plików z 12 dodań i 8 usunięć

Wyświetl plik

@ -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,
}
}
})

Wyświetl plik

@ -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]
ukhas_str = ukhas_format(datum)
habitat_upload(datum['time'], ukhas_str)
for datum in data[3:]:
ukhas_str = ukhas_format(datum)
try:
print ukhas_str
print habitat_upload(datum['time'], ukhas_str)
except:
None