コード例 #1
0
ファイル: gltf2usd.py プロジェクト: treeniap/gltf2usd
def check_usd_compliance(rootLayer, arkit=False):
    #An API change in v18.11 changed the sytax for UsdUtils.ComplianceChecker...
    if Usd.GetMinorVersion() >= 18 and Usd.GetPatchVersion() >= 11:
        checker = UsdUtils.ComplianceChecker(arkit=arkit, skipARKitRootLayerCheck=False)
        checker.CheckCompliance(rootLayer)
    else:
        #Behavior in v18.09
        checker = UsdUtils.ComplianceChecker(rootLayer, arkit=arkit, skipARKitRootLayerCheck=False)

    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()
    for msg in errors + failedChecks:
        print(msg)
    return len(errors) == 0 and len(failedChecks) == 0
コード例 #2
0
def check_usd_compliance(rootLayer, arkit=False):
    checker = UsdUtils.ComplianceChecker(rootLayer,
                                         arkit=arkit,
                                         skipARKitRootLayerCheck=False)
    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()
    for msg in errors + failedChecks:
        print(msg)
    return len(errors) == 0 and len(failedChecks) == 0
コード例 #3
0
def _CheckCompliance(rootLayer, arkit=False):
    checker = UsdUtils.ComplianceChecker(arkit=arkit, 
        # We're going to flatten the USD stage and convert the root layer to 
        # crate file format before packaging, if necessary. Hence, skip these 
        # checks.
        skipARKitRootLayerCheck=True)
    checker.CheckCompliance(rootLayer)
    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()
    for msg in errors + failedChecks:
        _Err(msg)
    return len(errors) == 0 and len(failedChecks) == 0
コード例 #4
0
def usd_check(inputFile, arkit=True, verbose=True):
    from pxr import UsdUtils
    checker = UsdUtils.ComplianceChecker(arkit=arkit, verbose=verbose,
                                         # skipARKitRootLayerCheck=False, rootPackageOnly=args.rootPackageOnly,
                                         # skipVariants=args.skipVariants
                                         )

    checker.CheckCompliance(inputFile)

    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()

    if len(errors) > 0 or len(failedChecks) > 0:
        for msg in errors + failedChecks:
            print(msg)
コード例 #5
0
def _CheckCompliance(rootLayer, arkit=False):
    checker = UsdUtils.ComplianceChecker(
        arkit=arkit,
        # We're going to flatten the USD stage and convert the root layer to
        # crate file format before packaging, if necessary. Hence, skip these
        # checks.
        skipARKitRootLayerCheck=True)
    checker.CheckCompliance(rootLayer)
    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()
    warnings = checker.GetWarnings()
    for msg in errors + failedChecks:
        _Err(msg)
    if len(warnings) > 0:
        _Err("*********************************************\n"
             "Possible correctness problems to investigate:\n"
             "*********************************************\n")
        for msg in warnings:
            _Err(msg)
    return len(errors) == 0 and len(failedChecks) == 0
コード例 #6
0
            assert UsdUtils.CreateNewARKitUsdzPackage(
                Sdf.AssetPath(args.assetPath), args.usdzFile,
                args.rename if args.rename else '')

    zipFile = Usd.ZipFile.Open(args.usdzFile)
    assert zipFile

    with stream(args.outfile, 'w') as ofp:
        for fileName in zipFile.GetFileNames():
            print >> ofp, fileName

    # Validate that the usdz file can be opened on a stage.
    stage = Usd.Stage.Open(args.usdzFile)
    assert stage

    if args.check:
        rootLayerPath = stage.GetRootLayer().realPath
        context = Ar.GetResolver().CreateDefaultContextForAsset(rootLayerPath)
        with Ar.ResolverContextBinder(context):
            checker = UsdUtils.ComplianceChecker(arkit=args.arkit,
                                                 verbose=True)
            checker.CheckCompliance(args.usdzFile)
            failedChecks = checker.GetFailedChecks()
            errors = checker.GetErrors()
            for msg in failedChecks + errors:
                print >> sys.stderr, msg
            assert args.numFailedChecks == len(failedChecks)
            assert args.numErrors == len(errors)

    sys.exit(0)
コード例 #7
0
def main():
    parser = argparse.ArgumentParser(
        description='Utility for checking the '
        'compliance of a given USD stage or a USDZ package.')

    parser.add_argument('inputFile',
                        type=str,
                        help='Name of the input file to inspect.')
    parser.add_argument('-s',
                        '--skipVariants',
                        dest='skipVariants',
                        action='store_true',
                        help='If specified, only the prims'
                        ' that are present in the default (i.e. selected) '
                        'variants are checked. When this option is not '
                        'specified, prims in all possible combinations of '
                        'variant selections are checked.')
    parser.add_argument('-p',
                        '--rootPackageOnly',
                        dest='rootPackageOnly',
                        action="store_true",
                        help='Check only the specified'
                        'package. Nested packages, dependencies and their '
                        'contents are not validated.')
    parser.add_argument('-o',
                        '--out',
                        dest='outFile',
                        type=str,
                        nargs='?',
                        default='-',
                        help='The file to which all the failed '
                        'checks are output. If unspecified, the failed checks '
                        'are output to stdout.')
    parser.add_argument(
        '--arkit',
        dest='arkit',
        action='store_true',
        help='Check if the given USD stage is compatible with '
        'ARKit\'s initial implementation of usdz. These assets '
        'operate under greater constraints that usdz files for '
        'more general in-house uses, and this option attempts '
        'to ensure that these constraints are met.')
    parser.add_argument('-d',
                        '--dumpRules',
                        dest='dumpRules',
                        action='store_true',
                        help='Dump the enumerated set of '
                        'rules being checked.')
    parser.add_argument('-v',
                        '--verbose',
                        dest='verbose',
                        action='store_true',
                        help='Enable verbose output mode.')

    args = parser.parse_args()
    inputFile = args.inputFile
    outFile = args.outFile

    checker = UsdUtils.ComplianceChecker(arkit=args.arkit,
                                         skipARKitRootLayerCheck=False,
                                         rootPackageOnly=args.rootPackageOnly,
                                         skipVariants=args.skipVariants,
                                         verbose=args.verbose)

    if args.dumpRules:
        checker.DumpRules()

    checker.CheckCompliance(inputFile)

    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()

    if len(errors) > 0 or len(failedChecks) > 0:
        with _Stream(outFile, 'w') as ofp:
            for msg in errors + failedChecks:
                # Add color if we're outputting to a terminal.
                if outFile == '-':
                    msg = TermColors.FAIL + msg + TermColors.END
                _Print(ofp, msg)
        print "Failed!"
        return 1

    print "Success!"
    return 0
コード例 #8
0
def main():
    parser = argparse.ArgumentParser(description="""Utility for checking the 
    compliance of a given USD stage or a USDZ package.  Only the first sample
    of any relevant time-sampled attribute is checked, currently.  General
    USD checks are always performed, and more restrictive checks targeted at
    distributable consumer content are also applied when the "--arkit" option
    is specified.""")

    parser.add_argument('inputFile', type=str, nargs='?', 
                        help='Name of the input file to inspect.')
    parser.add_argument('-s', '--skipVariants', dest='skipVariants',
                        action='store_true', help='If specified, only the prims'
                        ' that are present in the default (i.e. selected) '
                        'variants are checked. When this option is not '
                        'specified, prims in all possible combinations of '
                        'variant selections are checked.')
    parser.add_argument('-p', '--rootPackageOnly', dest='rootPackageOnly', 
                        action="store_true", help='Check only the specified'
                        'package. Nested packages, dependencies and their '
                        'contents are not validated.')
    parser.add_argument('-o', '--out', dest='outFile', type=str, nargs='?',
                        default='-', help='The file to which all the failed '
                        'checks are output. If unspecified, the failed checks '
                        'are output to stdout.')
    parser.add_argument('--noAssetChecks', dest='noAssetChecks', 
                        action='store_true', help='If specified, do NOT perform '
                        'extra checks to help ensure the stage or '
                        'package can be easily and safely referenced into '
                        'aggregate stages.')
    parser.add_argument('--arkit', dest='arkit', action='store_true', 
                        help='Check if the given USD stage is compatible with '
                        'ARKit\'s initial implementation of usdz. These assets '
                        'operate under greater constraints that usdz files for '
                        'more general in-house uses, and this option attempts '
                        'to ensure that these constraints are met.')
    parser.add_argument('-d', '--dumpRules', dest='dumpRules', 
                        action='store_true', help='Dump the enumerated set of '
                        'rules being checked for the given set of options.')
    parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
                        help='Enable verbose output mode.')

    args = parser.parse_args()
    inputFile = args.inputFile
    outFile = args.outFile
    
    checker = UsdUtils.ComplianceChecker(arkit=args.arkit, 
                                         skipARKitRootLayerCheck=False, 
                                         rootPackageOnly=args.rootPackageOnly, 
                                         skipVariants=args.skipVariants, 
                                         verbose=args.verbose,
                                         assetLevelChecks=not args.noAssetChecks)

    if not args.dumpRules and not args.inputFile:
        parser.error("Either an inputFile or the --dumpRules option must be"
                     "specified.")

    if args.dumpRules:
        checker.DumpRules()
        # If there's no input file to check, exit after dumping the rules.
        if args.inputFile is None:
            return 0

    checker.CheckCompliance(inputFile)

    warnings = checker.GetWarnings()
    errors = checker.GetErrors()
    failedChecks = checker.GetFailedChecks()
    
    with _Stream(outFile, 'w') as ofp:
        if len(warnings) > 0:
            for msg in warnings:
                # Add color if we're outputting to a terminal.
                if outFile == '-':
                    msg = TermColors.WARN + msg  + TermColors.END
                _Print(ofp, msg)
        
        if len(errors)> 0 or len(failedChecks) > 0:
            for msg in errors + failedChecks:
                # Add color if we're outputting to a terminal.
                if outFile == '-':
                    msg = TermColors.FAIL + msg  + TermColors.END
                _Print(ofp, msg)
            print("Failed!")
            return 1

    if len(warnings) > 0:
        print("Success with warnings...")
    else:
        print("Success!")
    return 0