def createFolder(): # First grab our path path = request.values['path'].strip("/") # Add the event to the queue event = requestEvent(params=(path), requestFunction=requestHandlers.createFolder) eventQueue.put(event) # Wait till the event is done while (not event.isDone): time.sleep(0.1) # Return the event and its status code return Response(status=event.status_code, response=event.response)
def retriveFileLastModified(): # First grab our path path = request.values['path'] # Add the event to the queue event = requestEvent( params=(path), requestFunction=requestHandlers.retriveFileLastModified) eventQueue.put(event) # Wait till the event is done while (not event.isDone): time.sleep(1) # Return the event and its status code return Response(status=event.status_code, response=event.response)
def moveFile(): # Grab our origin and destination origin = request.values['origin'].strip("/") destination = request.values['destination'].strip("/") # Add the event to the queue event = requestEvent(params=(origin, destination), requestFunction=requestHandlers.moveFile) eventQueue.put(event) # Wait till the event is done while (not event.isDone): time.sleep(1) # Return the event and its status code return Response(status=event.status_code, response=event.response)
def uploadFile(): # First grab our file and path toUpload = request.files['file'] path = request.values['path'].strip("/") # Add the event to the queue event = requestEvent(params=path, requestFunction=requestHandlers.uploadFile, fileToUpload=toUpload, uploadsFile=True) eventQueue.put(event) # Wait till the event is done while (not event.isDone): time.sleep(1) # Return the event and its status code return Response(status=event.status_code, response=event.response)
def retriveFile(): # First grab our path path = request.values['path'] # Add the event to the queue event = requestEvent(params=(path), requestFunction=requestHandlers.retriveFile, returnsFile=True) eventQueue.put(event) # Wait till the event is done while (not event.isDone): time.sleep(1) # Return the event and its status code if (event.status_code == 200): return send_file(event.absolutePath, attachment_filename=event.attachment_filename) # Unless an error came up return Response(status=event.status_code, response=event.response)