Almost there

This commit is contained in:
2020-11-14 12:08:27 +00:00
parent 6038d40b27
commit c4a121cbd2
2 changed files with 13 additions and 12 deletions

View File

@@ -111,14 +111,14 @@ func getSnapshotFromPythonScript() (*SnapshotSubmission, error) {
)
}
tokens := strings.Split(string(output), "\n")
if len(tokens) != 4 {
if len(tokens) != 5 {
return nil, errors.New(fmt.Sprintf("Strange python output: %s", output))
}
snapshot := SnapshotSubmission{
Timestamp: tokens[0],
Temp: tokens[1],
Humidity: tokens[2],
Co2: tokens[3],
Timestamp: strings.Split(tokens[0], "\t")[1],
Temp: strings.Split(tokens[1], "\t")[1],
Humidity: strings.Split(tokens[2], "\t")[1],
Co2: strings.Split(tokens[3], "\t")[1],
}
return &snapshot, nil
}
@@ -142,4 +142,4 @@ func internalErrorOnErr(err error, w http.ResponseWriter, r *http.Request) bool
func logError(errorMessage string) {
fmt.Println(errorMessage)
mainLogger.Println(errorMessage)
}
}