Esempio n. 1
0
    def test(self):

        checker = os.path.expandvars(
            "$GAFFER_ROOT/python/GafferCortexTest/images/checker.exr")
        checker = IECore.Reader.create(checker).read()

        node = GafferCortex.ObjectWriter()
        node["fileName"].setValue(self.__exrFileName)
        node["in"].setValue(checker)

        self.assertEqual(node["fileName"].getValue(), self.__exrFileName)
        self.assertEqual(node["in"].getValue(), checker)

        # check that there are plugs for the writer parameters,
        # but not for the fileName parameter.

        writer = IECore.Writer.create(checker, self.__exrFileName)

        for k in writer.parameters().keys():
            if k != "fileName" and k != "object":
                self.failUnless(k in node["parameters"])

        self.failIf("fileName" in node["parameters"])

        # check that saving it works

        self.failIf(os.path.exists(self.__exrFileName))
        with Gaffer.Context():
            node["task"].execute()
        self.failUnless(os.path.exists(self.__exrFileName))

        checker2 = IECore.Reader.create(self.__exrFileName).read()
        self.assertEqual(checker, checker2)
Esempio n. 2
0
    def testHash(self):

        c = Gaffer.Context()
        c.setFrame(1)
        c2 = Gaffer.Context()
        c2.setFrame(2)

        s = Gaffer.ScriptNode()
        s["n"] = GafferCortex.ObjectWriter()

        # no file produces no effect
        self.assertEqual(s["n"].hash(c), IECore.MurmurHash())

        # no input object produces no effect
        s["n"]["fileName"].setValue(self.__exrFileName)
        self.assertEqual(s["n"].hash(c), IECore.MurmurHash())

        # now theres a file and object, we get some output
        s["sphere"] = GafferTest.SphereNode()
        s["n"]["in"].setInput(s["sphere"]["out"])
        self.assertNotEqual(s["n"].hash(c), IECore.MurmurHash())

        # output doesn't vary by time
        self.assertEqual(s["n"].hash(c), s["n"].hash(c2))

        # output varies by time since the file name does
        s["n"]["fileName"].setValue(self.__exrSequence.fileName)
        self.assertNotEqual(s["n"].hash(c), s["n"].hash(c2))
Esempio n. 3
0
    def testExtraneousPlugsAfterSerialisation(self):

        s = Gaffer.ScriptNode()
        s["n"] = GafferCortex.ObjectWriter()
        s["n"]["fileName"].setValue(self.__exrFileName)

        self.failUnless("parameters" in s["n"])
        self.failIf("parameters1" in s["n"])

        ss = s.serialise()

        s = Gaffer.ScriptNode()
        s.execute(ss)

        self.failUnless("parameters" in s["n"])
        self.failIf("parameters1" in s["n"])
Esempio n. 4
0
    def testChangingFileType(self):

        checker = os.path.expandvars(
            "$GAFFER_ROOT/python/GafferCortexTest/images/checker.exr")
        checker = IECore.Reader.create(checker).read()

        node = GafferCortex.ObjectWriter()
        node["fileName"].setValue(self.__exrFileName)
        node["in"].setValue(checker)

        node["fileName"].setValue(self.__tifFileName)

        with Gaffer.Context():
            node["task"].execute()
        self.failUnless(os.path.exists(self.__tifFileName))

        self.failUnless(IECore.TIFFImageReader.canRead(self.__tifFileName))
Esempio n. 5
0
    def testChangingFileType(self):

        checker = os.path.expandvars(
            "$GAFFER_ROOT/python/GafferCortexTest/images/checker.exr")
        checker = IECore.Reader.create(checker).read()

        node = GafferCortex.ObjectWriter()
        node["fileName"].setValue(self.__exrFileName)
        node["in"].setValue(checker)

        node["fileName"].setValue(self.__tifFileName)

        with Gaffer.Context():
            node["task"].execute()
        self.assertTrue(os.path.exists(self.__tifFileName))

        image = IECoreImage.ImageReader(self.__tifFileName).read()
        self.assertIn("tiff:Compression", image.blindData())
Esempio n. 6
0
	def testStringSubstitutions( self ) :

		checker = os.path.expandvars( "$GAFFER_ROOT/python/GafferCortexTest/images/checker.exr" )
		checker = IECore.Reader.create( checker ).read()

		node = GafferCortex.ObjectWriter()
		node["fileName"].setValue( self.__exrSequence.fileName )
		node["in"].setValue( checker )

		contexts = []
		for i in self.__exrSequence.frameList.asList() :
			context = Gaffer.Context()
			context.setFrame( i )
			with context :
				node["task"].execute()

		for f in self.__exrSequence.fileNames() :
			self.failUnless( os.path.exists( f ) )
Esempio n. 7
0
    def testHash(self):

        c = Gaffer.Context()
        c.setFrame(1)
        c2 = Gaffer.Context()
        c2.setFrame(2)

        s = Gaffer.ScriptNode()
        s["n"] = GafferCortex.ObjectWriter()

        # no file produces no effect
        with c:
            self.assertEqual(s["n"]["task"].hash(), IECore.MurmurHash())

        # no input object produces no effect
        with c:
            s["n"]["fileName"].setValue(self.__exrFileName)
            self.assertEqual(s["n"]["task"].hash(), IECore.MurmurHash())

        # now theres a file and object, we get some output
        with c:
            s["o"] = GafferTest.CachingTestNode()
            s["n"]["in"].setInput(s["o"]["out"])
            self.assertNotEqual(s["n"]["task"].hash(), IECore.MurmurHash())

        # output doesn't vary by time
        with c:
            h1 = s["n"]["task"].hash()
        with c2:
            h2 = s["n"]["task"].hash()

        self.assertEqual(h1, h2)

        # output varies by time since the file name does
        s["n"]["fileName"].setValue(self.__exrSequence.fileName)
        with c:
            h1 = s["n"]["task"].hash()
        with c2:
            h2 = s["n"]["task"].hash()

        self.assertNotEqual(h1, h2)