Skip to content

Instantly share code, notes, and snippets.

@bjnortier
Created October 5, 2016 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjnortier/ddd93a9412e1cc6cd66e2ae5166a2180 to your computer and use it in GitHub Desktop.
Save bjnortier/ddd93a9412e1cc6cd66e2ae5166a2180 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import picamera
import time
import requests
import json
import sys
from senio_config import SenioConfig
config = SenioConfig()
while True:
camera = picamera.PiCamera()
camera.vflip = True
camera.hflip = True
camera.capture('img720x480.jpg')
camera.close()
try:
response = requests.post(
config.url,
headers={
'Authorization': 'Bearer {}'.format(config.key)
},
files={
config.values['camera_field']: open('img720x480.jpg', 'rb')
},
data={
'json': json.dumps({
'timestamp': time.time()*1000
})
})
print('Status: {}'.format(response.status_code))
print('Content: {}'.format(response.content))
except:
print('Unexpected error:', sys.exc_info()[0])
time.sleep(600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment