Exemplo n.º 1
0
def install_scripts_directory():

    blender_scripts_search_root_dir = get_python_scripts_directory()
    blender_scripts_install_dir = get_blender_scripts_install_dir()

    blender_scripts_current_dir = find_blender_scripts_directory(blender_scripts_search_root_dir)

    if blender_scripts_current_dir is not None:

        print("Found Blender scripts directory at " + blender_scripts_current_dir)

        if str(pathlib.Path(blender_scripts_current_dir).parent.absolute()).casefold() == blender_scripts_install_dir.casefold():

            print(blender_scripts_current_dir+" already direct child of "+blender_scripts_install_dir)

        else:

            print("Moving "+blender_scripts_current_dir+" to "+blender_scripts_install_dir)

            shutil.move(blender_scripts_current_dir, 
                        os.path.join(blender_scripts_install_dir, 
                                     os.path.basename(blender_scripts_current_dir)))

    else:

        raise BlenderScriptsDirUnknownError("Could not find Blender scripts "
                                            "directory in "
                                            +blender_scripts_search_root_dir)
Exemplo n.º 2
0
def remove_blender_scripts_dir():
    """Find and remove the blender scripts directory
    """

    blender_scripts_search_root_dir = get_blender_scripts_install_dir()

    blender_scripts_current_dir = find_blender_scripts_directory(
        blender_scripts_search_root_dir)

    if blender_scripts_current_dir is not None:

        print("Found blender scripts dir at " + blender_scripts_current_dir)
        print("Removing " + blender_scripts_current_dir)

        shutil.rmtree(blender_scripts_current_dir)

    else:

        print("Did not find Blender scripts at post_install script location")
        print("Did you forget to perform bpy_post_install after installing?")
        print("Searching original pip install location")

        blender_scripts_search_root_dir = get_python_scripts_directory()

        blender_scripts_current_dir = find_blender_scripts_directory(
            blender_scripts_search_root_dir)

        if blender_scripts_current_dir is not None:

            print("Found blender scripts dir at " +
                  blender_scripts_current_dir)
            print("Removing " + blender_scripts_current_dir)

            shutil.rmtree(blender_scripts_current_dir)

        else:

            raise BlenderScriptsDirUnknownError(
                "Could not find Blender scripts "
                "directory in " + blender_scripts_search_root_dir)