def move_services(filename, j, num_ext):
    # move to services folder

    file_path = filename.rsplit('.', num_ext)[0]
    src_path = path.join(app.config['UPLOAD_FOLDER'], file_path, file_path)
    dest_path = app.config['SERVICES_FOLDER']

    i = 0
    while i != -1:
        try:
            src_path_i = path.join(app.config['UPLOAD_FOLDER'], file_path, file_path+str(i))
            src_path_ii = path.join(app.config['UPLOAD_FOLDER'], file_path, file_path+str(i-1))
            if i == 0:
                mv(src_path, dest_path)
            elif i == 1:
                mv(src_path, dest_path_i)
                mv(dest_path_i, dest_path)
            else:
                mv(dest_path_ii, dest_path_i)
                mv(dest_path_i, dest_path)
            j = i
            i = -1
        except:
            i += 1

    # remove leftover files in tmp
    remove(path.join(app.config['UPLOAD_FOLDER'], filename))
    rmtree(path.join(app.config['UPLOAD_FOLDER'], file_path))
    return j
dataset/ETHPy150Open cglewis/wharf/wharf/forms.py/move_services/original