habitat_upload: attempt to get time correct on habhub

Works for couchdb, but then wrong on the mobile tracker
master
Richard Meadows 2015-08-01 22:02:48 +01:00
rodzic 13f1d9fe59
commit 3f11b52e8d
2 zmienionych plików z 14 dodań i 11 usunięć

Wyświetl plik

@ -10,17 +10,21 @@ from datetime import datetime
couch = couchdb.Server('http://habitat.habhub.org/')
db = couch['habitat']
def habitat_upload(packet_string):
def habitat_upload(rx_time, packet_string):
print packet_string
packet_base64 = base64.standard_b64encode(packet_string+"\n")
print packet_base64
packet_sha256 = hashlib.sha256(packet_base64).hexdigest()
print packet_sha256
# 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 time_uploaded
print db.save({
"type":"payload_telemetry",
@ -30,8 +34,8 @@ def habitat_upload(packet_string):
},
"receivers": {
"BACKLOG": {
"time_created": time_uploaded,
"time_uploaded": time_uploaded
"time_created": time_created,
"time_uploaded": time_created,
}
}
})

Wyświetl plik

@ -140,7 +140,6 @@ with open(file_name, 'r') as data_file:
print "%s: %s, %s" % ((str(datum['time']),) + datum['coords'][:2])
# Upload data to habitat
datum = data[0]
datum = data[2]
ukhas_str = ukhas_format(datum)
print ukhas_str
habitat_upload(ukhas_str)
habitat_upload(datum['time'], ukhas_str)