Beispiel #1
0
    def testLoad(self):

        p = GafferCortex.ClassLoaderPath(IECore.ClassLoader.defaultOpLoader(),
                                         "/mesh/normals")

        op = p.load()()
        self.failUnless(isinstance(op, IECore.Op))
Beispiel #2
0
    def testLoad(self):

        p = GafferCortex.ClassLoaderPath(IECore.ClassLoader.defaultOpLoader(),
                                         "/files/sequenceRenumber")

        op = p.load()()
        self.failUnless(isinstance(op, IECore.Op))
	def testRelative( self ) :

		p = GafferCortex.ClassLoaderPath( IECore.ClassLoader.defaultOpLoader(), "files" )
		self.assertEqual( str( p ), "files" )
		self.assertEqual( p.root(), "" )
		self.assertTrue( "files/sequenceRenumber" in [ str( c ) for c in p.children() ] )

		p2 = p.copy()
		self.assertEqual( str( p2 ), "files" )
		self.assertEqual( p2.root(), "" )
		self.assertTrue( "files/sequenceRenumber" in [ str( c ) for c in p2.children() ] )
Beispiel #4
0
    def loadOP( self, path, newVersion=1 ) :
        self.classType = '/'.join(path.split('/')[0:2])

        app = GafferCortex.ClassLoaderPath( IECore.ClassLoader.defaultOpLoader(), "/asset/publish" ).load()()

        # load the type op so we can run it
        opNames = Asset.AssetParameter().classLoader.classNames( "*%s" % '/'.join(path.split('/')[:2]) )
        app.parameters()['Asset']['type'].setClass(opNames[0],1)

        try:
            j = pipe.admin.job()
        except:
            j=None

        if j:
            try:
                import maya.cmds as m
                from maya.mel import eval as meval
                # m.ls()
            except:
                m = None


            data = Asset.AssetParameter(j.path('sam/')+str(path)).getData()

            for each in data['assetClass'].keys():
                if each in app.parameters()['Asset']['type'].keys():
                    if app.parameters()['Asset']['type'][each].getValue() == app.parameters()['Asset']['type'][each].defaultValue:
                        app.parameters()['Asset']['type'][each].setValue( data['assetClass'][each] )

            for each in data['assetInfo'].keys():
                if 'version' in each:
                    from glob import glob
                    versions = glob("%s/../??.??.??" % data['path'])
                    versions.sort()
                    # print versions
                    v = [ int(x) for x in versions[-1].split('/')[-1].split('.') ]

                    app.parameters()['Asset']['info'][each].setValue( IECore.V3i(v[0], v[1]+newVersion, v[2]) )
                elif 'description' in each:
                    pass
                #     app.parameters()['Asset']['info'][each].setValue( "\n"+data['assetInfo'][each].value )
                else:
                    app.parameters()['Asset']['info'][each].setValue( data['assetInfo'][each] )


        # print "BUMM"
        app.parameters()['Asset'].parameterChanged()
        return app
	def testProperties( self ) :

		p = GafferCortex.ClassLoaderPath( IECore.ClassLoader.defaultOpLoader(), "/files" )

		self.assertEqual( p.propertyNames(), [ "name", "fullName", "classLoader:versions" ])
		self.assertEqual( p.property( "name" ), "files" )
		self.assertEqual( p.property( "fullName" ), "/files" )
		self.assertEqual( p.property( "classLoader:versions" ), None )

		p.append( "sequenceRenumber" )

		self.assertEqual( p.propertyNames(), [ "name", "fullName", "classLoader:versions" ])
		self.assertEqual( p.property( "name" ), "sequenceRenumber" )
		self.assertEqual( p.property( "fullName" ), "/files/sequenceRenumber" )
		self.assertTrue( isinstance( p.property( "classLoader:versions" ), IECore.IntVectorData ) )
Beispiel #6
0
    def test(self):

        p = GafferCortex.ClassLoaderPath(IECore.ClassLoader.defaultOpLoader(),
                                         "/")
        self.failUnless(p.isValid())
        self.failIf(p.isLeaf())

        p.append("files")
        self.failUnless(p.isValid())
        self.failIf(p.isLeaf())

        p.append("iDontExist")
        self.failIf(p.isValid())
        self.failIf(p.isLeaf())

        del p[-1]
        self.failUnless(p.isValid())
        self.failIf(p.isLeaf())

        p.setFromString("/files/sequenceRenumber")
        self.failUnless(p.isValid())
        self.failUnless(p.isLeaf())

        p.setFromString("/files")
        children = p.children()
        for child in children:
            self.failUnless(isinstance(child, GafferCortex.ClassLoaderPath))
            self.assertEqual(len(child), len(p) + 1)
            self.failUnless(child.isLeaf())

        children = [str(x) for x in children]
        self.failUnless("/files/sequenceCopy" in children)
        self.failUnless("/files/sequenceLs" in children)
        self.failUnless("/files/sequenceMove" in children)

        p.setFromString("/")
        children = p.children()
        for child in children:
            self.failUnless(isinstance(child, GafferCortex.ClassLoaderPath))
            self.assertEqual(len(child), len(p) + 1)

        p.setFromString("/mesh/normals")
        self.assertTrue(p.isLeaf())
        versions = p.info()["classLoader:versions"]
        self.failUnless(isinstance(versions, IECore.IntVectorData))
        self.failUnless(len(versions))
Beispiel #7
0
    def _initialPath(self):

        return GafferCortex.ClassLoaderPath(self.__classLoader, "/")
Beispiel #8
0
                    m.scriptJob( kill=int(job[0]), force=True )
            __scriptJob( runOnce=runOnce,  idleEvent=idleEvent )
            # print [ str(x).strip().split(':') for x in m.scriptJob(listJobs=True) if idleEvent.func_name in x ]

        if event:
            # print '====>',idleEvent.func_name
            if _jobs:
                jobs =  [ str(x).strip().split(':') for x in _jobs if event[1].func_name in x and "'%s'" % event[0] in x ]
                for job in jobs:
                    m.scriptJob( kill=int(job[0]), force=True )
            __scriptJob( runOnce=runOnce,  event=event )
            # print [ str(x).strip().split(':') for x in m.scriptJob(listJobs=True) if event[1].func_name in x ]



__publishOP__ = GafferCortex.ClassLoaderPath( IECore.ClassLoader.defaultOpLoader(), "/asset/publish" ).load()
def loadAssetOP( path, newVersion=1, data=None ) :
    classType = '/'.join(path.split('/')[0:2])

    app = __publishOP__()

    # load the type op so we can run it
    opNames = Asset.AssetParameter().classLoader.classNames( "*%s" % '/'.join(path.split('/')[:2]) )
    app.parameters()['Asset']['type'].setClass(opNames[0],0)

    if j:
        if not data:
            data = Asset.AssetParameter(path).getData()
        if data:
            app.parameters()['Asset']['info'].setValue( data['assetInfo'] )
            app.parameters()['Asset']['type'].setValue( data['assetClass'] )