def checkForImages(this, onNew, diff): if(not this.flag): print "Called incorrectly" return def callback(response): #print response.body if(type(response.body) is list): #print "check for new:", response.body this.ids += response.body[0] this.images += response.body[1] for x in xrange(len(this.images) - len(response.body[1]), len(this.images)): temp = this.images[x] this.images[x] = this.images[x - diff] this.images[x - diff] = temp print type(this.images[x - diff]) onNew(this.images[x - diff]) else: #print "Error (1)" pass this.flag = False asyncHttp.get(this.serverUrl + "/imagesGet", {"images": this.ids}, callback)
def sendImage(this, image, flag, final): if(flag == "end"): asyncHttp.get(this.serverUrl + "/imagesPost", {"user": this.user, "data": "end"}, final) elif(flag == "start"): #We're at the start asyncHttp.get(this.serverUrl + "/imagesPost", {"user": this.user, "data": "start"}, lambda x: this.sendImage(image, 0, final)) else: #data transmission if(len(image) <= flag): this.sendImage(image, "end", final) else: asyncHttp.get(this.serverUrl + "/imagesPost", {"user": this.user, "data": image[flag:min(flag + this.chunkSize, len(image))]}, lambda x: this.sendImage(image, flag + this.chunkSize, final))