예제 #1
0
	def setUp( self ) :

		GafferTest.TestCase.setUp( self )

		sanitiser = GafferImageTest.ContextSanitiser()
		sanitiser.__enter__()
		self.addCleanup( sanitiser.__exit__, None, None, None )
예제 #2
0
    def __writeImage(self, script, args):

        import GafferImage
        import GafferImageTest

        image = script.descendant(args["image"].value)
        if isinstance(image, Gaffer.Node):
            image = next(GafferImage.ImagePlug.RecursiveOutputRange(image),
                         None)

        if image is None:
            IECore.msg(IECore.Msg.Level.Error, "stats",
                       "Image \"%s\" does not exist" % args["image"].value)
            return

        contextSanitiser = _NullContextManager()
        if args["contextSanitiser"].value:
            contextSanitiser = GafferImageTest.ContextSanitiser()

        frames = self.__frames(script, args)

        def computeImage():

            with self.__context(script, args) as context:
                for frame in frames:
                    context.setFrame(frame)
                    GafferImageTest.processTiles(image)

        if args["preCache"].value:
            computeImage()

        memory = _Memory.maxRSS()
        with self.__performanceMonitor or _NullContextManager(
        ), self.__contextMonitor or _NullContextManager(
        ), self.__vtuneMonitor or _NullContextManager():
            with contextSanitiser:
                with _Timer() as imageTimer:
                    computeImage()

        self.__timers["Image generation"] = imageTimer
        self.__memory["Image generation"] = _Memory.maxRSS() - memory

        with self.__context(script, args) as context:
            items = [
                ("Format", image["format"].getValue()),
                ("Data window", image["dataWindow"].getValue()),
                ("Channel names", image["channelNames"].getValue()),
            ]

        self.__output.write("\nImage :\n\n")
        self.__writeItems(items)