Skip to content

collect_scene_render_cleanup

Collect persistent environment file to be deleted.

CollectSceneRenderCleanUp

Bases: InstancePlugin

Collect files and directories to be cleaned up

Source code in client/ayon_deadline/plugins/publish/global/collect_scene_render_cleanup.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class CollectSceneRenderCleanUp(pyblish.api.InstancePlugin):
    """Collect files and directories to be cleaned up
    """

    order = pyblish.api.CollectorOrder - 0.1
    label = "Collect Scene Render Clean Up"
    targets = ["farm"]

    def process(self, instance):
        representations : List[Dict] = instance.data.get("representations", [])
        staging_dirs: List[str] = []
        files : List[str] = []
        for repre in representations:
            staging_dir = repre.get("stagingDir")
            for filename in os.listdir(staging_dir):
                base, _ = os.path.splitext(filename)
                if not base.endswith("_tmp"):
                    continue
                staging_dirs.append(staging_dir)
                files.append(os.path.join(staging_dir, filename))

            # Check for blender temporary dir
            blender_tmp_dir = os.path.join(staging_dir, "tmp")
            if not os.path.exists(blender_tmp_dir):
                blender_tmp_dir = os.path.join(
                    os.path.dirname(staging_dir), "tmp")
                if not os.path.exists(blender_tmp_dir):
                    continue
            staging_dirs.append(blender_tmp_dir)
            for tmp_file in os.listdir(blender_tmp_dir):
                files.append(os.path.join(blender_tmp_dir, tmp_file))

        instance.context.data["cleanupFullPaths"].extend(files)
        self.log.debug(f"Files to clean up: {files}")
        instance.context.data["cleanupEmptyDirs"].extend(staging_dirs)
        self.log.debug(f"Staging dirs to clean up: {staging_dirs}")