def move_dir():
    if request.method=='POST':
        new_dir = request.form.getlist('filelist')#('dataArray')
        destination = request.form.get('destination')#('dataArray')
        sub_dir = pathClass.subPath()
        destination = os.path.join(current_user.getFileDir(),sub_dir,destination)
        for files in new_dir:
            fileName = os.path.join(current_user.getFileDir(),sub_dir,files)
            shutil.move(fileName,os.path.join(destination,files))
        return 'success'
def rename():
    if request.method=='POST':
        renameNameWE = request.form.get('rename-id')
        renameName, renameExt = os.path.splitext(renameNameWE)
        filesTorenameInU = request.form.getlist('file-name')
        filesTorename = [x.encode('UTF8') for x in filesTorenameInU]
        counter = 0;
        for file in filesTorename:
            sub_dir = pathClass.subPath()
            curr_dir = os.path.join(current_user.getFileDir(),sub_dir)
            filePath = os.path.join(curr_dir,file)
            if(counter ==0):
                newFilePath = os.path.join(curr_dir,(renameName+renameExt))
            else:
                newFilePath = os.path.join(curr_dir,(renameName+"("+str(counter)+")")+renameExt)
            if ~os.path.exists(newFilePath):
                os.rename(filePath,newFilePath)
                counter+=1
            else:
                while(os.path.exists(newFilePath)):
                    counter+=1
                    newFilePath = os.path.join(curr_dir,(renameName+"("+str(counter)+")")+renameExt)
                os.rename(filePath,newFilePath)
                counter+=1
    return "rename done"
def video_info():
    filename = request.get_data()
    sub_dir = pathClass.subPath()
    videoFile = cv2.VideoCapture(os.path.join(current_user.getFileDir(), sub_dir, filename))
    totalCount = videoFile.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)
    videoFormat = videoFile.get(cv2.cv.CV_CAP_PROP_FORMAT)
    return json.dumps({"totalCount": totalCount, "videoFormat": videoFormat})
def get_files():
    if current_user.is_authenticated():
        curr_dir = current_user.getFileDir()
        sub_dir = pathClass.subPath()
        fileList = files.createFileList(curr_dir,sub_dir)
        return fileList
    else:
        return redirect(url_for('index'))
def done_potree():
    if request.method=='POST':
        folder_id = request.form.get('folder_id')
        if(folder_id==None):
            sub_dir = pathClass.subPath()
        else:
          sub_dir = pathClass.subPath() + folder_id + '/'
        if(os.path.isfile(os.path.join(current_user.getFileDir(),sub_dir,'potree/potree.dat'))):
            file = open(os.path.join(current_user.getFileDir(),sub_dir,'potree/potree.dat'),'r+')
            checkVal = file.read()
            file.close()
            if(checkVal == '100'):
                return "true"
            else:
                return "false"
        else:
            return "false"
def done_potree():
    if request.method == "POST":
        folder_id = request.form.get("folder_id")
        if folder_id == None:
            sub_dir = pathClass.subPath()
        else:
            sub_dir = pathClass.subPath() + folder_id + "/"
        if os.path.isfile(os.path.join(current_user.getFileDir(), sub_dir, "potree/potree.dat")):
            file = open(os.path.join(current_user.getFileDir(), sub_dir, "potree/potree.dat"), "r+")
            checkVal = file.read()
            file.close()
            if checkVal == "100":
                return "true"
            else:
                return "false"
        else:
            return "false"
def get_image_dir():    
    if request.args.get('type')== '1':
        return send_file(os.path.join(current_user.getImageDir(),'file.png'), mimetype='image/png')
    elif request.args.get('type')=='2':
        return send_file(os.path.join(current_user.getImageDir(),'folder.png'), mimetype='image/png')
    elif request.args.get('type')=='3':
        return send_file(os.path.join(current_user.getImageDir(),'video.png'), mimetype='image/png')
    elif request.args.get('type')!=None:
        sub_dir = pathClass.subPath()
        return send_file(os.path.join(current_user.getFileDir(),sub_dir,request.args.get('type')), mimetype='image')
def get_image_dir():
    if request.args.get("type") == "1":
        return send_file(os.path.join(current_user.getImageDir(), "file.png"), mimetype="image/png")
    elif request.args.get("type") == "2":
        return send_file(os.path.join(current_user.getImageDir(), "folder.png"), mimetype="image/png")
    elif request.args.get("type") == "3":
        return send_file(os.path.join(current_user.getImageDir(), "video.png"), mimetype="image/png")
    elif request.args.get("type") != None:
        sub_dir = pathClass.subPath()
        return send_file(os.path.join(current_user.getFileDir(), sub_dir, request.args.get("type")), mimetype="image")
def create_directory():
    if request.method == "POST":
        new_dir = request.form.get("newfolder_id")
        sub_dir = pathClass.subPath()
        curr_dir = os.path.join(current_user.getFileDir(), sub_dir, new_dir)
        if os.path.exists(curr_dir):
            print "already exists"
        else:
            os.makedirs(curr_dir)
        return "success"
Beispiel #10
0
def delete():
    if request.method=='POST':
        filesToDeleteInU = request.form.getlist('file_name')
        filesToDelete = [x.encode('UTF8') for x in filesToDeleteInU]
        for file in filesToDelete:
            sub_dir = pathClass.subPath()
            curr_dir = os.path.join(current_user.getFileDir(),sub_dir)
            filePath = os.path.join(curr_dir,file)
            if os.path.exists(filePath):
                os.remove(filePath)
        return 'success'
Beispiel #11
0
def delete_directory():
    if request.method=='POST':
        folderToDeleteInU = request.form.getlist('folder_name')
        folderToDelete = [x.encode('UTF8') for x in folderToDeleteInU]
        for folder in folderToDelete:
	        sub_dir = pathClass.subPath()
	        curr_dir = os.path.join(current_user.getFileDir(),sub_dir)
	        folderPath = os.path.join(curr_dir, folder)
	        if os.path.exists(folderPath):
                    shutil.rmtree(folderPath)
	        else:
	            print "no path"
        return 'success'
Beispiel #12
0
def run_pmvs():
    if request.method=='POST':
        folder_id = request.form.get('folder_id')
        if(folder_id==None):
            return 0
        else:
          sub_dir = pathClass.subPath() + folder_id + '/'
        #subprocess.call([os.getcwd()+'/scripts/run_pmvs.sh'])
        if(not(os.path.exists(os.path.join(current_user.getFileDir(),sub_dir,'pmvs')))):
            os.makedirs(os.path.join(current_user.getFileDir(),sub_dir,'pmvs'))
        pmvs_data = os.path.join(current_user.getFileDir(),sub_dir,'pmvs/pmvs.dat')
        if(not(os.path.isfile(pmvs_data))):
            file = open(pmvs_data, 'w+')
            file.write('100')
            file.close()
        else:
            file = open(pmvs_data, 'w+')
            file.write('100')
            file.close()
        file = open(pmvs_data, 'r+')
        progress = file.read()
        return progress
def run_pmvs():
    if request.method == "POST":
        folder_id = request.form.get("folder_id")
        if folder_id == None:
            return 0
        else:
            sub_dir = pathClass.subPath() + folder_id + "/"
        # subprocess.call([os.getcwd()+'/scripts/run_pmvs.sh'])
        if not (os.path.exists(os.path.join(current_user.getFileDir(), sub_dir, "pmvs"))):
            os.makedirs(os.path.join(current_user.getFileDir(), sub_dir, "pmvs"))
        pmvs_data = os.path.join(current_user.getFileDir(), sub_dir, "pmvs/pmvs.dat")
        if not (os.path.isfile(pmvs_data)):
            file = open(pmvs_data, "w+")
            file.write("100")
            file.close()
        else:
            file = open(pmvs_data, "w+")
            file.write("100")
            file.close()
        file = open(pmvs_data, "r+")
        progress = file.read()
        return progress
Beispiel #14
0
def upload():
    if current_user.is_authenticated():
        if request.method=='POST':
            file = request.files.get('upload-file')
            sub_dir = pathClass.subPath()
            curr_dir = os.path.join(current_user.getFileDir(),sub_dir)
            if file and allowed_file(file.filename):
                filename = secure_filename(file.filename)
                file.save(os.path.join(curr_dir, file.filename))
                name, ext = os.path.splitext(file.filename)
                filetypes = files.fileParser(ext)
                return jsonify({"filename": file.filename, "filetype": filetypes, "status":'<i class="glyphicon glyphicon-ok"></i>'})
    else:
	     return redirect(url_for('index'))       
def upload():
    if current_user.is_authenticated():
        if request.method == "POST":

            filelist = request.files.getlist("fileData")
            sub_dir = pathClass.subPath()
            curr_dir = os.path.join(current_user.getFileDir(), sub_dir)
            for file in filelist:
                if file and allowed_file(file.filename):
                    filename = secure_filename(file.filename)
                    file.save(os.path.join(curr_dir, file.filename))
                    name, ext = os.path.splitext(file.filename)
                    filetypes = files.fileParser(ext)
            return "success"
        else:
            return redirect(url_for("index"))
    def generate():
        filename = request.form["filename"]
        framerate = int(request.form["framerate"])
        sub_dir = pathClass.subPath()
        videoFile = cv2.VideoCapture(os.path.join(current_user.getFileDir(), sub_dir, filename))
        ffp = videoFile.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT) - int(request.form["ffp"])
        newFolderName = os.path.splitext(filename)[0]
        newFolderDir = ""
        i = 1

        # check whether path exists and create path based upon video file name
        print "path making.."
        if os.path.exists(os.path.join(current_user.getFileDir(), sub_dir, newFolderName)):
            while os.path.exists(os.path.join(current_user.getFileDir(), sub_dir, newFolderName + " " + str(i))):
                i = i + 1
            os.makedirs(os.path.join(current_user.getFileDir(), sub_dir, newFolderName + " " + str(i)))
            newFolderDir = os.path.join(current_user.getFileDir(), sub_dir, newFolderName + " " + str(i))
        else:
            os.makedirs(os.path.join(current_user.getFileDir(), sub_dir, newFolderName))
            newFolderDir = os.path.join(current_user.getFileDir(), sub_dir, newFolderName)

        print "pathmaking complete"
        count = 0
        totalCount = videoFile.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT) / (framerate + 1)
        videoFile.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, ffp)

        totalZeros = int(math.floor(math.log(totalCount, 10)))
        while True:
            f, img = videoFile.read()

            if framerate != 0:
                for _ in range(framerate):
                    f, img = videoFile.read()
                    if not f:
                        break
            if not f:
                break
            cv2.imwrite(os.path.join(newFolderDir, "image_" + (str(count).zfill(totalZeros + 1)) + ".jpg"), img)
            count = count + 1
            red.publish("updates", count / totalCount)

        return "success"