def test_common_path_when_duplicate_entries_of_single_path(self):
     d = PathList()
     files = [
         "/users/joebloggs/tmp/foo.txt", "/users/joebloggs/tmp/foo.txt"
     ]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp/foo.txt"))
Beispiel #2
0
    def _get_output_directory(self):
        """
        Get the common path for all image output paths.

        NOTE: We don't really need the subpaths any longer because directory
        creation is handled in the prerender script. Don't want to mess with
        things right now though.

        Returns:
            dict: common path and list of paths below it
        """
        out_paths = PathList()

        images = ix.api.OfObjectArray()
        self.node.get_attribute("images_and_layers").get_values(images)

        for image in images:
            directory = os.path.dirname(
                image.get_attribute("save_as").get_string())
            try:
                out_paths.add(directory)
            except ValueError as ex:
                ix.log_error("{} - while resolving {}".format(
                    str(ex), directory))
        return {
            "common_path": out_paths.common_path(),
            "output_paths": out_paths
        }
 def test_common_path_when_one_path_is_the_common_path(self):
     d = PathList()
     files = [
         "/users/joebloggs/tmp",
         "/users/joebloggs/tmp/bolly/operation",
         "/users/joebloggs/tmp/stay/go",
     ]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
 def test_common_path(self):
     d = PathList()
     files = [
         "/users/joebloggs/tmp/foobar/test",
         "/users/joebloggs/tmp/baz/fripp",
         "/users/joebloggs/tmp/elephant/corner",
     ]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
 def test_common_path_when_common_prefix_in_filename(self):
     d = PathList()
     files = [
         "/users/joebloggs/tmp/dissention/perfect",
         "/users/joebloggs/tmp/disagreement/crimson",
         "/users/joebloggs/tmp/diatribe/belew",
     ]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
 def test_common_different_drive_letter(self):
     d = PathList()
     files = [
         "D://users/joebloggs/tmp/foo.txt",
         "D://users/joebloggs/tmp/modelman.jpg",
         "C://users/joebloggs/tmp/ration.cpp",
         "C://users/joebloggs/tmp/bill.project",
     ]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/"))
 def test_common_path_when_lowest_path_is_the_common_path(self):
     d = PathList()
     files = [
         "/users/joebloggs/tmp/foo.txt",
         "/users/joebloggs/tmp/modelman.jpg",
         "/users/joebloggs/tmp/ration.cpp",
         "/users/joebloggs/tmp/bill.project",
     ]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/users/joebloggs/tmp"))
Beispiel #8
0
def _validate_images(node):
    """
    Check that images or layers are present and set up to be rendered.

    Also check that the when there are many output paths, their common path is
    not the filesystem root, as this will be the submission's output_path
    property.

    Args:
        node (ConductorJob): Node
    """
    images = ix.api.OfObjectArray()
    node.get_attribute("images_and_layers").get_values(images)
    out_paths = PathList()
    if not images.get_count():
        ix.log_error(
            "No render images. Please reference one or more image items")

    for image in images:
        if not image.get_attribute("render_to_disk").get_bool():
            ix.log_error(
                "Image does not have render_to_disk attribute set: {}".format(
                    image.get_full_name()))

        save_path = image.get_attribute("save_as").get_string()
        if not save_path:
            ix.log_error("Image save_as path is not set: {}".format(
                image.get_full_name()))
        if save_path.endswith("/"):
            ix.log_error("Image save_as path must be a filename, \
                not a directory: {}".format(image.get_full_name()))

        try:
            directory = os.path.dirname(save_path)
            out_paths.add(directory)
        except ValueError as ex:
            ix.log_error("{} - while resolving {}".format(str(ex), directory))

    common_path = out_paths.common_path()

    paths = "\n".join(p.posix_path() for p in out_paths)

    if common_path.depth == 0:
        ix.log_error(
            "Your output files should be rendered to a common subfolder.  Not the filesystem root. {}\n{}"
            .format(common_path.posix_path(), paths))
 def test_common_path_is_slash_when_root(self):
     d = PathList()
     files = ["/users/joebloggs/tmp/foo.txt", "/dev/joebloggs/tmp/foo.txt"]
     d.add(*files)
     self.assertEqual(d.common_path(), Path("/"))
 def test_common_path_is_none_when_no_entries(self):
     d = PathList()
     self.assertIsNone(d.common_path())