wire it all together
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-08-25 01:40:09 +02:00
parent 5d9e815407
commit 15f369446c
8 changed files with 114 additions and 12 deletions

View File

@@ -1,5 +1,11 @@
#!/usr/bin/env python3
import os
import json
import logging
from datetime import datetime
import requests
from .abcsender import AbcSender
from utils import config
"""
Send a sound sample
@@ -15,9 +21,22 @@ class SoundSender(AbcSender):
"""
SoundSender class, responsible for sending sound samples to the cloud.
"""
def sendvalue(self, value, decision):
def sendvalue(self, value: str, decision: bool) -> None:
"""
Send a sound sample to the cloud.
:return:
"""
pass
if decision:
files = {
"file": (os.path.basename(value), open(value, 'rb').read(), 'audio/wave',
{'Content-length': os.path.getsize(value)}),
"description": (
None, json.dumps({'date': datetime.now().isoformat(), 'device_id': config.DEVICE_ID}),
"application/json")
}
r = requests.post(config.INPUT_SVC_URL, files=files)
logging.info("Content: ", r.content)
logging.info("Headers:", r.headers)
r.raise_for_status()