def recurseProcessData(data, parents=parent, depth=0, atype=[]):
            if data:
                keys = data.keys()
                keys.sort()
                current = [depth]
                if '__current__' in keys:
                    current = data['__current__']
                    del keys[keys.index('__current__')]
                for d in keys:
                    fullpath = '/'.join(atype + [d])
                    op = None
                    assetSourceExistsInHost = None
                    if '__current__' in data[d].keys():
                        fullpath += '/%s' % os.path.basename(
                            data[d]['__current__'].strip('/'))

                    if depth > 1:
                        op = assetUtils.assetOP(fullpath)
                        assetSourceExistsInHost = op.assetSourceExistsInHost()

                    if depth == 0:
                        parents.appendChild(
                            TreeItem(('---', '', '', None), parents))

                    parents.appendChild(
                        TreeItem((d, current, fullpath, op,
                                  assetSourceExistsInHost), parents))
                    recurseProcessData(data[d], parents.child(-1), depth + 1,
                                       atype + [d])

                if depth == 0:
                    self.ready = parents
Beispiel #2
0
    def __init__( self, asset, name = "RenderMayaPublish" ) :

        super(RenderMayaPublish, self).__init__( name )

        self.op = assetUtils.assetOP(asset)
        self.op.loadOP()
        self.setParameterised(self.op.op)
Beispiel #3
0
def _getData(*p):
    import assetUtils, Asset, genericAsset
    import time, os, sys
    import IECore
    # self = p[0][0]
    path = p[0]
    data = {}
    data['asset'] = path

    if os.path.isdir(path):
        # print p
        op = assetUtils.assetOP(path.split('sam/')[1])
        op.loadOP()
        data = op.data
        data['whoCanImport'] = op.subOP._whoCanImport
        data['whoCanOpen'] = op.subOP._whoCanOpen
        data['nodeName'] = genericAsset._nodeName(data)
        data['stat'] = os.stat(path + '/data.txt')
        # data['op']           = IECore.ParameterParser().Serialize(op.op.parameters())
        # data['subOP']        = IECore.ParameterParser().Serialize(op.subOP.parameters())
        for n in data.keys():
            if 'IECore' in str(data[n]):
                data[n] = str(data[n])

        ap = path.split('sam/')[1]
        _loadOP_all[ap] = data
        data['asset'] = ap

    return data
 def __SAM_assetList_doImport__():
     import genericAsset
     pb = genericAsset.progressBar(
         len(paths) + 1, "Importing assets...")
     for path in paths:
         pb.step()
         print path
         op = assetUtils.assetOP(path)
         op.doImport()
     pb.step()
     pb.close()
     self._mayaNodeDeleted()
Beispiel #5
0
            def recursiveTree(path, d={}, d2={}, f='', l=0, threads=threads):
                # print path
                if l >= 5:
                    return d
                for each in glob("%s/*" % path):
                    if f in each:
                        id = each.replace(path, '')[1:]
                        if os.path.isdir(each):
                            # try:
                            #     data = Asset.AssetParameter(each.replace(j.path('sam/'),'')).getData()
                            #     # id = id+" (%s)" % data['assetUser']
                            #     zdata[each] = data
                            # except:
                            #    pass
                            # if l!=2 or len(id.split('.'))==1 or isAsset or shot == id.split('.')[0] :
                            # if l==2:
                            #     print shot ,id
                            # sys.stdout.flush()

                            d[id] = {}
                            if os.path.exists('%s/data.txt' % each):
                                # data = Asset.AssetParameter(each.replace(j.path('sam/'),'')).getData()
                                op = assetUtils.assetOP(
                                    each.split(folderName)[1][1:])
                                print op.pathPar
                                op.loadOP()
                                data = op.data
                                data['whoCanImport'] = op.subOP._whoCanImport
                                data['whoCanOpen'] = op.subOP._whoCanOpen
                                data['nodeName'] = genericAsset._nodeName(data)
                                for n in data.keys():
                                    if 'IECore' in str(data[n]):
                                        data[n] = str(data[n])
                                # d[id]['__data__'] = open('%s/data.txt' % each, 'r').readlines()
                                # print data
                                d[id]['data'] = data

                            # id2 = ( id if id[0].isdigit() and len(id.split('.'))>2 else id.split('.')[-1] )
                            # d2[id2] = {}
                            # recursiveTree(each, d[id], d2[id2],l=l+1)

                            recursiveTree(each, d[id], {}, l=l + 1)
                            # threads += [threading.Thread(target=recursiveTree,args=(each, d[id], {},'',l+1,threads,))]
                            # threads[-1].start()

                        elif 'current' in each:
                            lines = ''.join(open(each).readlines()).replace(
                                '\n', '')
                            d['__current__'] = lines
                        #    d[id] = False
                return d
Beispiel #6
0
def loadOP(*p):
    # print p
    path = p[0]
    import assetUtils, Asset, genericAsset
    import time, os, threading, sys
    from glob import glob
    from multiprocessing import Pool

    r = _loadOP_all
    i = path.split('sam')[1].strip('/').split('/')

    if i[0] not in r:
        r[i[0]] = {}
    if i[1] not in r[i[0]]:
        r[i[0]][i[1]] = {}
    if i[2] not in r[i[0]][i[1]]:
        r[i[0]][i[1]][i[2]] = {}
    if i[3] not in r[i[0]][i[1]][i[2]]:
        if 'current' in i[3]:
            lines = ''.join(open(path).readlines()).replace('\n', '')
            r[i[0]][i[1]][i[2]]['__current__'] = lines.strip()
        else:
            r[i[0]][i[1]][i[2]][i[3]] = {}

            op = assetUtils.assetOP(path.split('sam/')[1])
            op.loadOP()
            data = op.data
            data['whoCanImport'] = op.subOP._whoCanImport
            data['whoCanOpen'] = op.subOP._whoCanOpen
            data['nodeName'] = genericAsset._nodeName(data)
            data['stat'] = os.stat(path + '/data.txt')
            for n in data.keys():
                if 'IECore' in str(data[n]):
                    data[n] = str(data[n])

            r[i[0]][i[1]][i[2]][i[3]]['data'] = data
    return r
 def createNewAsset(paths, assetType):
     op = assetUtils.assetOP(assetType)
     op.newPublish()
 def __SAM_assetList_mayaOpenDependency__():
     # print paths
     for path in paths:
         # print path
         op = assetUtils.assetOP(path)
         op.mayaOpenDependency()
 def updateAsset(asset):
     op = assetUtils.assetOP(asset[0])
     op.updatePublish()