Beispiel #1
0
 def check_required_args(self):
     """
     Check on required properies.
     If a required property does not exist throw a LayerException.
     """
     for key, rtype in self.__req_args:
         if not self.__args.has_key(key):
             msg = "The %s layer requires the %s property to be set."
             raise LayerException(msg % (self, key))
         if rtype:
             if not isinstance(self.__args[key], rtype):
                 msg = "The %s layer requires %s to be of the type %s"
                 raise LayerException(msg % (self, key, rtype))
Beispiel #2
0
    def set_parent(self, layer):
        """Set the parent layer."""

        if not isinstance(layer, (Layer)):
            raise LayerException("Parent instance must derive from Layer.")

        self.__parent = layer
Beispiel #3
0
    def getLocalFrameSet(self, frame):
        """
        Return the local frameset when running in execute mode.
        """
        frameset = None

        if self.getChunk() <= 0:
            frameset = self.getFrameSet()
        elif self.getChunk() >1:
            result = []

            full_range = self.getFrameSet()
            end = len(full_range) - 1

            idx = full_range.index(frame)
            print "idx :%d" % idx
            for i in range(idx, idx+self.getChunk()):
                if i > end:
                    break
                result.append(full_range[i])
            frameset = fileseq.FrameSet(",".join(map(str, result)))
        else:
            frameset = fileseq.FrameSet(str(frame))

        if frameset is None:
            raise LayerException("Unable to determine local frameset.")

        return frameset
Beispiel #4
0
 def set_type(self, t):
     """
     Sets the general scope/purpose of this layer.
     """
     if t not in constants.LAYER_TYPES:
         raise LayerException("%s is not a valid layer type: %s" %
                              (t, constants.LAYER_TYPES))
     self.__type = t
Beispiel #5
0
 def check_input(self, frame_set=None):
     """
     Check the existance of all required input.  Raise a LayerException
     if input is missing.
     """
     for name, inpt in self.__input.iteritems():
         if not inpt.get_attribute("checked"):
             continue
         if not inpt.exists(frame_set):
             msg = "Check input failed (%s), the path %s does not exist."
             raise LayerException(msg % (name, inpt.get_path()))
Beispiel #6
0
    def set_name(self, name):
        """
        Set the layer's name.

        @type name: str
        @param name: A name for the layer.
        """
        if self.__outline and self.__outline.get_mode() > 1:
            msg = "Layer names may only be changed in outline init mode."
            raise LayerException(msg)
        self.__name = name
Beispiel #7
0
    def get_output(self, name):
        """
        Return the named output.

        @rtype:  outline.io.Path
        @return: the assoicated io.Path object from the given name.
        """
        try:
            return self.__output[name]
        except:
            raise LayerException("An output by the name %s does not exist." %
                                 name)
Beispiel #8
0
    def set_arg(self, key, value):
        """Set the value of key."""

        for arg, rtype in self.__req_args:
            if arg == key and rtype:
                if not isinstance(value, rtype):
                    msg = "The arg %s for the %s module must be a %s"
                    raise LayerException(msg %
                                         (arg, self.__class__.__name__, rtype))
                else:
                    break
        self.__args[key] = value
Beispiel #9
0
    def add_child(self, layer):
        """
        Add a child layer to this layer. Child layers are
        executed  after the parent layer.
        """
        if not isinstance(layer, (Layer)):
            raise LayerException("Child instances must derive from Layer.")

        layer.set_outline(self.get_outline())
        layer.set_parent(self)

        self.__children.append(layer)
        layer.after_parented(self)
Beispiel #10
0
    def add_output(self, name, output):
        """
        Add an output to this layer.
        """
        if not name:
            name = "output%d" % len(self.__output)
        name = str(name)
        if self.__output.has_key(name):
            msg = "An output with the name %s has already been created."
            raise LayerException(msg % name)

        if not isinstance(output, io.Path):
            output = io.Path(output)

        self.__output[name] = output
Beispiel #11
0
    def get_local_frame_set(self, start_frame):
        """
        Set the local frame set.  The local frame set is the frame
        list that must be handled by the execute() function.  The local
        frame set can have more than one frame when chunk_size is greater
        than 1.

        @type    start_frame: int
        @param   start_frame: the starting of the frame set.
        """
        chunk = self.get_chunk_size()

        if chunk == 1:
            return util.make_frame_set([int(start_frame)])
        else:
            local_frame_set = []
            #
            # Remove the duplicates out of our frame range.
            #
            frame_range = FileSequence.FrameSet(self.get_frame_range())
            frame_set = util.deaggregate_frame_set(frame_range)

            #
            # Now find the index for the current frame and start
            # frame there. Find all of frames this instance
            # is responsible for.
            #
            idx = frame_set.index(int(start_frame))
            for i in xrange(idx, idx + chunk):
                try:
                    if frame_set[i] in local_frame_set:
                        continue
                    local_frame_set.append(frame_set[i])
                except IndexError:
                    break
            if not local_frame_set:
                raise LayerException(
                    "Frame %d is outside of the frame range." % start_frame)
            else:
                return util.make_frame_set(local_frame_set)
Beispiel #12
0
 def putData(self, name, data):
     if not self.__job:
         raise LayerException("The layer %s requires a job to be set setup() is run." % self.__name)
     if not self.__job.getArchive():
         raise LayerException("A job archive must exist before dynamic data can be added.")
     self.__job.getArchive().putData(name, data, self)