commit 10/24/2015
This commit is contained in:
66
test.py
66
test.py
@@ -3,26 +3,78 @@ from instruments import Camera_Debug2 as Camera
|
||||
from datahandling import Datareporter_Debug3 as Datareporter
|
||||
import serial
|
||||
import sys
|
||||
import json
|
||||
|
||||
REPORTIMAGETOURL = "http://10.0.1.4:5010/photo"
|
||||
|
||||
LOG_FILE = "log2.txt"
|
||||
|
||||
data = {"temp":1,"press":3,"altitude":2,"cheetas":"just enough"}
|
||||
import binascii
|
||||
|
||||
import base64
|
||||
from base64 import urlsafe_b64encode
|
||||
|
||||
reporter = Datareporter ()
|
||||
with open('log2.txt','rb') as f:
|
||||
g=f.read()
|
||||
e=urlsafe_b64encode(g)
|
||||
|
||||
camera = Camera(low_quality_resolution=(320, 180),
|
||||
low_quality_compression_pct=50)
|
||||
# a=binascii.b2a_uu(f)
|
||||
|
||||
image = camera.capture()
|
||||
# e = f.encode('base64')
|
||||
|
||||
print (image)
|
||||
# e = str(e, "ascii")
|
||||
|
||||
data = {"temp":1,
|
||||
"press":3,
|
||||
"altitude":2,
|
||||
"image":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
}
|
||||
|
||||
# data = json.dumps(data,ensure_ascii=True)
|
||||
|
||||
# camera = Camera(low_quality_resolution=(320, 180),
|
||||
# low_quality_compression_pct=50)
|
||||
|
||||
# image = camera.capture()
|
||||
|
||||
# print (image)
|
||||
|
||||
pass
|
||||
from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
|
||||
|
||||
|
||||
# i=open('resized_image.jpg','rb')
|
||||
# r=i.read()
|
||||
|
||||
# def callback(encoder, bytes_read):
|
||||
# # Do something with this information
|
||||
# pass
|
||||
#
|
||||
# monitor = MultipartEncoderMonitor.from_fields(
|
||||
# fields={'field0': 'value0'}, callback
|
||||
# )
|
||||
|
||||
|
||||
|
||||
# m = MultipartEncoder(fields={"field":("image", open("resized_image.jpg", 'rb'), "image/jpeg")})
|
||||
#
|
||||
reporter = Datareporter (content_type="form-data")
|
||||
#
|
||||
# f = open('resized_image.jpg','rb')
|
||||
# r=f.read()
|
||||
|
||||
#report image
|
||||
# reporter.send(image.get('file'), type="image")
|
||||
# response = requests.post("http://home.ascorrea.com:5010/upload-file", data=m.read())
|
||||
# print(type(r))
|
||||
# reporter.send(str(r)[2:-5].replace("\\\", "\\"), type="image")
|
||||
# reporter.send("Content-Disposition: {0}; name=\"{1}\"; filename=\"{2}\" {4}".format(
|
||||
# 'application/octet-stream',
|
||||
# 'field',
|
||||
# 'resized_image',
|
||||
# 'image/jpeg',""), type="image")
|
||||
|
||||
|
||||
|
||||
reporter.send(data, type="image")
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user