import requests
import sys
import os
import time
import threading
import os
import queue
# operator where will be shown result and process
target = op('result')
frameStart = op('execute1')
# queue for thread
myQ = queue.Queue()
#parameters need to send
number = me.parent().par.Number
idN = str( number )
pr_key = str( me.parent().par.Key )
image1 = 'data/img/' + op.number.op('data').text + "/" + str( number ) + '.jpg'
#store thread result in the target OP
target.store('myQ', myQ)
def sendImage(image1, N, PK, myQ):
myQ.put("Processing")
# url upload to
url = 'http://src.sokaris.cn/photobooth/uploadMain.php'
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
# files and data to send
file1 = open(image1,'rb')
files = {'fileToUpload1': file1}
values = {'key': PK, 'id': N,'submit': 'submit'}
try:
r = requests.post(url, files=files, data=values, headers=headers)
myQ.put(r.text)
except requests.ConnectionError:
myQ.put("900")
file1.close()
return
frameStart.par.framestart = 1
myThread = threading.Thread(target=sendImage, args=( image1, idN, pr_key, myQ,))
myThread.start()
# me - this DAT
#
# frame - the current frame
#reading from queue and write it into target DAT
def start():
return
def create():
return
def exit():
return
def frameStart(frame):
try:
myQ = op('result').fetch('myQ')
value = myQ.get_nowait()
op('result')[0, 0] = value
if value != 'Processing':
me.par.framestart = 0
except:
pass
return
def frameEnd(frame):
return
def playStateChange(state):
return
def deviceChange():
return