80 lines
1.8 KiB
Python
80 lines
1.8 KiB
Python
import csv, requests
|
|
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"
|
|
|
|
import binascii
|
|
|
|
import base64
|
|
from base64 import urlsafe_b64encode
|
|
|
|
with open('log2.txt','rb') as f:
|
|
g=f.read()
|
|
e=urlsafe_b64encode(g)
|
|
|
|
# a=binascii.b2a_uu(f)
|
|
|
|
# e = f.encode('base64')
|
|
|
|
# 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
|
|
# 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 |