def test1():
    print ''
    print 'TEST 1 ' + ('=' * 80)

    # time
    start = 1001
    end = 1010
    middle = start + ((end - start) * 0.5)

    # New scene
    mayaUtils.reinitializeScene(frameRange=(start, end))

    # create camera
    tfm, shp = mayaUtils.createCameraAsset('renderCamera')
    maya.cmds.setAttr(shp + '.renderable', 1)
    maya.cmds.setKeyframe(tfm, at='translateX', t=start, v=0.0)
    maya.cmds.setKeyframe(tfm, at='translateY', t=end, v=5.0)
    maya.cmds.setKeyframe(tfm, at='translateZ', t=middle, v=-10.0)
    mayaUtils.saveTestFile('test1_before')

    # do checks
    ctx = context.Context()
    lib.run(ctx=ctx)

    # save the scene
    mayaUtils.saveTestFile('test1_after')
    return
Exemple #2
0
 def test_run(self):
     print 'Test Name:', self.id()
     root = self.rootPath()
     data = {'someData': 42}
     stdUtils.createGenericAsset(name='myAsset', root=root, data=data)
     ctx = context.Context(root=root)
     lib.run(ctx=ctx)
     return
Exemple #3
0
 def test_runBadPath(self):
     print 'Test Name:', self.id()
     root = os.path.abspath('/')
     ctx = context.Context(root=root)
     if os.name != 'nt':
         self.assertRaises(OSError, lib.run, ctx)
     else:
         self.assertRaises(WindowsError, lib.run, ctx)
     return
Exemple #4
0
    def test_geometryValidator(self):
        print 'Test Name:', self.id()
        root = self.rootPath()

        name = 'geom'
        data = {'shapes': [], 'faceNum': -1, 'vertNum': -1}
        cam = stdUtils.createGeometryAsset(root=root, name=name, data=data)

        ctx = context.Context(root=root)
        lib.run(ctx=ctx)
        return
Exemple #5
0
    def test_runSimpleAssets(self):
        print 'Test Name:', self.id()
        root = self.rootPath()

        renderCam = stdUtils.createRenderCameraAsset(root=root)
        plateA = stdUtils.createPlateAsset(name='A', root=root)
        trackCamA = stdUtils.createTrackCameraAsset(subName='A', root=root)
        geom = stdUtils.createSphereGeomAsset(root=root)

        ctx = context.Context(root=root)
        lib.run(ctx=ctx)
        return
Exemple #6
0
    def test_cameraValidator(self):
        print 'Test Name:', self.id()
        root = self.rootPath()

        name = 'camera'
        data = {
            'focalLength': 50.0,
            'filmBackWidth': 42.0,
            'filmBackHeight': 42.0
        }
        cam = stdUtils.createCameraAsset(root=root, name=name, data=data)

        ctx = context.Context(root=root)
        lib.run(ctx=ctx)
        return
Exemple #7
0
    def test_three(self):
        print 'Test Name:', self.id()
        root = self.rootPath()

        renderCam = stdUtils.createRenderCameraAsset(root=root)

        plateA = stdUtils.createPlateAsset(name='A', root=root)
        plateB = stdUtils.createPlateAsset(name='B', root=root)

        trackCamA = stdUtils.createTrackCameraAsset(subName='A', root=root)
        trackCamB = stdUtils.createTrackCameraAsset(subName='B', root=root)

        geom = stdUtils.createSphereGeomAsset(root=root)

        metalShd = stdUtils.createMetalShaderAsset(root=root)
        woodShd = stdUtils.createWoodShaderAsset(root=root)

        # do checks
        ctx = context.Context(root=root)
        lib.run(ctx=ctx)
        return
Exemple #8
0
    def run(self):
        self.resetLogText()

        self.updateFindMode()
        self.__context = context.Context(find=self.__find_mode)

        doValidators = self.getRunValidatorsValue()
        doFixers = self.getRunFixersValue()
        doReporters = self.getRunReportersValue()

        # Run...
        lib.run(ctx=self.__context,
                doCollectors=True,
                doValidators=doValidators,
                doFixers=doFixers,
                doReporters=doReporters,
                progressCb=self.progressCb)

        # Update UI
        self.updateInfoText()
        self.updateTree()
        return
def test3():
    print ''
    print 'TEST 3 ' + ('=' * 80)

    # New Scene
    start = 1001
    end = 1010
    mayaUtils.reinitializeScene(frameRange=(start, end))

    # create camera
    tfm, shp = mayaUtils.createCameraAsset('renderCamera')
    maya.cmds.setAttr(shp + '.renderable', 1)
    maya.cmds.setKeyframe(tfm, at='rotateX', t=start, v=0.0)
    maya.cmds.setKeyframe(tfm, at='rotateY', t=start, v=-0.0)
    maya.cmds.setKeyframe(tfm, at='rotateZ', t=start, v=-0.0)

    # create cube rig
    cube = maya.cmds.polyCube()[0]
    ctrl = maya.cmds.circle(nr=(0, 1, 0), radius=2)[0]
    mayaUtils.createRigAsset(name='characterCubeName',
                             geomList=[cube],
                             ctrlList=[ctrl])
    maya.cmds.setKeyframe(ctrl, at='translateX', t=start, v=1.0)
    maya.cmds.setKeyframe(ctrl, at='translateY', t=start, v=-3.0)
    maya.cmds.setKeyframe(ctrl, at='translateZ', t=start, v=-4.0)
    maya.cmds.setKeyframe(ctrl, at='translateX', t=end, v=-1.0)
    maya.cmds.setKeyframe(ctrl, at='translateY', t=end, v=3.0)
    maya.cmds.setKeyframe(ctrl, at='translateZ', t=end, v=4.0)

    # save file
    mayaUtils.saveTestFile('test3_before')

    # do checks
    ctx = context.Context()
    lib.run(ctx=ctx)

    # save the scene
    mayaUtils.saveTestFile('test3_after')
    return
Exemple #10
0
def test7():
    print ''
    print 'TEST 7 ' + ('=' * 80)

    # new scene
    start = 1001
    end = 1010
    mayaUtils.reinitializeScene(frameRange=(start, end))

    # create geometry
    sphere = maya.cmds.polySphere()[0]
    geomList = [sphere]
    geomSet = mayaUtils.createGeometryAsset(name='sphereGeom',
                                            geomList=geomList)
    mayaUtils.saveTestFile('test7_before')

    # do checks
    ctx = context.Context()
    lib.run(ctx=ctx)

    # save the scene
    mayaUtils.saveTestFile('test7_after')
    return
Exemple #11
0
def run(ctx=None,
        assetType=None,
        doCollectors=True,
        doValidators=True,
        doFixers=True,
        doReporters=True,
        logger=None,
        progressCb=None):
    """
    Runs asset quality checking.

    :param ctx: Context to run in, or None to create a new one.
    :param assetType: Asset type to operate on, or None to inducate all types.
    :param doCollectors: Run asset collection?
    :param doValidators: Run asset validation?
    :param doFixers: Run automatic fixers?
    :param doReporters: Run reporters to report QC results?
    :param logger: Logging object, or None.
    :param progressCb: Callback function to be used to display progress.
    
    :type ctx: assetQC.api.context.Context
    :type assetType: str
    :type doCollectors: bool
    :type doValidators: bool
    :type doFixers: bool
    :type doReporters: bool
    :type logger: assetQC.api_tests.logger.Logger
    :type progressCb: function
    :return:
    """
    msg = 'Initializing Context...'
    assetQC.api.utils.printProgressNum(msg,
                                       START_PERCENT,
                                       progressCb,
                                       logger=logger)
    if not ctx:
        print 'Created new context'
        ctx = context.Context()
    assert isinstance(ctx, context.Context)

    if logger is None:
        logger = assetQC.api.logger.getLogger()
    if progressCb is None:
        progressCb = logger.progress

    # collectors step.
    if doCollectors:
        msg = 'Running Collectors...'
        assetQC.api.utils.printProgressNum(msg,
                                           COLLECTOR_MIN,
                                           progressCb,
                                           logger=logger)
        ctx = _runCollection(ctx,
                             assetType=assetType,
                             progressCb=progressCb,
                             logger=logger)
        if not ctx.getInstances(sortByName=True):
            msg = 'Cannot find any instances: {instances!r}'
            msg = msg.format(instances=ctx.getInstances(sortByName=True))
            logger.warning(msg)

            msg = 'Finished Asset QC'
            assetQC.api.utils.printProgressNum(msg,
                                               FINISH_PERCENT,
                                               progressCb,
                                               logger=logger)
            return

    # validators step
    if doCollectors and doValidators:
        msg = 'Running Validators...'
        assetQC.api.utils.printProgressNum(msg,
                                           VALIDATOR_MIN,
                                           progressCb,
                                           logger=logger)
        ctx = _runValidation(ctx, assetType=assetType, progressCb=progressCb)

    # fixers step.
    if doCollectors and doValidators and doFixers:
        msg = 'Running Fixers...'
        assetQC.api.utils.printProgressNum(msg,
                                           FIXER_MIN,
                                           progressCb,
                                           logger=logger)
        ctx = _runFixers(ctx, progressCb=progressCb)

    # reporter step.
    if doCollectors and doValidators and doReporters:
        msg = 'Report Output...'
        assetQC.api.utils.printProgressNum(msg,
                                           PROCESS_MIN,
                                           progressCb,
                                           logger=logger)
        _runReporters(ctx, assetType=assetType, progressCb=progressCb)

    msg = 'Finished Asset QC'
    assetQC.api.utils.printProgressNum(msg,
                                       FINISH_PERCENT,
                                       progressCb,
                                       logger=logger)
Exemple #12
0
def test2():
    print ''
    print 'TEST 2 ' + ('=' * 80)

    # New Scene
    start = 1001
    end = 1010
    mayaUtils.reinitializeScene(frameRange=(start, end))

    # create cameras
    tfm1, shp1 = mayaUtils.createCameraAsset('camera1')
    tfm2, shp2 = mayaUtils.createCameraAsset('camera2')
    tfm3, shp3 = mayaUtils.createCameraAsset('camera3')
    tfm4, shp4 = mayaUtils.createCameraAsset('camera4')
    maya.cmds.setAttr(shp1 + '.renderable', 1)
    maya.cmds.setAttr(shp2 + '.renderable', 1)
    maya.cmds.setAttr(shp3 + '.renderable', 0)
    maya.cmds.setAttr(shp4 + '.renderable', 1)
    maya.cmds.setAttr(shp4 + '.horizontalFilmAperture', 1.0)
    maya.cmds.setAttr(shp4 + '.verticalFilmAperture', 1.0)
    maya.cmds.setAttr('persp.renderable', 0)
    maya.cmds.setKeyframe(tfm1, at='rotateX', t=start, v=0.0)
    maya.cmds.setKeyframe(tfm1, at='rotateY', t=start, v=-0.0)
    maya.cmds.setKeyframe(tfm1, at='rotateZ', t=start, v=-0.0)

    # create sphere rig
    sphere = maya.cmds.polySphere()[0]
    ctrl = maya.cmds.circle(nr=(0, 1, 0), radius=2)[0]
    mayaUtils.createRigAsset(name='characterSphereName',
                             geomList=[sphere],
                             ctrlList=[ctrl])

    # create cube rig
    cube = maya.cmds.polyCube()[0]
    ctrl = maya.cmds.circle(nr=(0, 1, 0), radius=2)[0]
    mayaUtils.createRigAsset(name='characterCubeName',
                             geomList=[cube],
                             ctrlList=[ctrl])

    # save scene before test
    mayaUtils.saveTestFile('test2_before')

    # Manually specify the plugins...
    mgr = register.PluginManager()

    # camera
    mgr.registerPlugin(cameraCollector.CameraCollector)
    mgr.registerPlugin(cameraRenderableValidator.CameraRenderableValidator)
    mgr.registerPlugin(
        cameraKeyframeCountValidator.CameraKeyframeCountValidator)
    mgr.registerPlugin(cameraFilmbackValidator.CameraFilmbackValidator)

    # rig
    mgr.registerPlugin(rigCollector.RigCollector)
    mgr.registerPlugin(rigValidator.RigValidator)

    # reporters
    mgr.registerPlugin(assignShadersReporter.AssignShadersReporter)
    mgr.registerPlugin(viewportRenderReporter.ViewportRenderReporter)

    # check context
    ctx = context.Context(pluginManager=mgr)

    # run check
    lib.run(ctx=ctx)

    # save the scene
    mayaUtils.saveTestFile('test2_after')
    return