def Main(): opts = ParseOpts() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2( iconrendering.APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) outdir = os.path.abspath(opts.outdir) name_deco = opts.deco iec_dir = opts.iecsource or GetLatestIECDirectory() if opts.zh: imageset_dir = opts.imagesetsource or IMAGE_SET_DEFAULT_PATH_ZH else: imageset_dir = opts.imagesetsource or IMAGE_SET_DEFAULT_PATH recipes = GetRecipes(name_deco, iec_dir, imageset_dir) L.debug('Outdir is: %s', outdir) for package in GetPackagesToProcess(opts): with DirectoryStaged(not opts.debug) as stagingdir: if opts.debug: L.debug('Using staging directory: %s', stagingdir) recipe = recipes[package] destfile = os.path.join(outdir, recipe.filename) if opts.debug: L.debug('Generating %s as %s.', package, destfile) ProcessPackage(recipe.dirs, stagingdir, destfile) sys.exit(0)
def Main(): opts = ParseOpts() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2( iconrendering.APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) out = os.path.join(opts.outroot, opts.outfolder) if opts.removedir: osutils.SafeRmTree(out) resmapper = fsdauthoringutils.GraphicsCache(devenv.EVEROOT) invmapper = inventory.InventoryMapper(opts.branch) _appsetup.CreateTrinityApp() mgr = rendermanagement.RenderManager(resmapper, invmapper, L, out, opts.takeonly) iec.DoRender(mgr, opts.takeonly, whatToRender=opts.imagebatch, logger=L) sys.exit(0)
def Main(): opts = ParseOpts() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2( iconrendering.APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) renderFolder = GetTmpRenderPath() if os.path.exists(renderFolder): osutils.SafeRmTree(renderFolder) resmapper = fsdauthoringutils.GraphicsCache(devenv.EVEROOT) invmapper = None _appsetup.CreateTrinityApp() mgr = rendermanagement.RenderManager(resmapper, invmapper, L, renderFolder, opts.takeonly) if opts.respath or opts.dna: mgr.RenderSingle(resPath=opts.respath, dnaString=opts.dna) else: mgr.RenderInGameIcons() if opts.checkout: L.debug('P4 Checkout started.') p4 = ccpp4.P4Init() dest_dict = GetDestDirs(renderFolder) before = set(map(string.lower, dest_dict.keys())) after = GetFiles(renderFolder) added = list(after.difference(before)) deleted = list(before.difference(after)) filesToCompare = list(after.intersection(before)) changed = [] for fileName in filesToCompare: iconResPath = dest_dict[fileName] renderPath = os.path.join(renderFolder, fileName) iconPath = respathutils.ExpandResPath(iconResPath, respathutils.GetClientRes()) if os.path.exists(iconPath): diffResult = imgdiff.ImgDiff(iconPath, renderPath, normal=False, alpha=False) error = diffResult['Color']['MeanAbsoluteError'] if error > TOLERANCE: changed.append(fileName) else: changed.append(fileName) if opts.checkout: for fileName in added + changed: iconResPath = dest_dict[fileName] iconPath = respathutils.ExpandResPath(iconResPath, respathutils.GetClientRes()) renderPath = os.path.join(renderFolder, fileName) L.debug('P4 Edit or Add: %s', fileName) p4.EditOrAdd(iconPath) icon_dir = os.path.dirname(iconPath) if not os.path.exists(icon_dir): os.makedirs(icon_dir) if os.path.exists(renderPath): shutil.copy(renderPath, iconPath) allfiles = added + changed GetPath = lambda fileName: respathutils.ExpandResPath( dest_dict[fileName], respathutils.GetClientRes()) if not (opts.takeonly or opts.respath): for deletedFile in deleted: L.debug('P4 Deleting: %s', deletedFile) p4.run_delete(GetPath(deletedFile)) allfiles = allfiles + deleted osfiles = map(GetPath, allfiles) depotFiles = map(lambda wh: wh['depotFile'], p4.run_where(osfiles)) if len(depotFiles): c = p4.Change(description='Ingame Icon generation.', files=depotFiles, save=False) changeno = p4.SaveChange(c) L.debug('P4 Checkout done.') if opts.cleanup: osutils.SafeRmTree(renderFolder)
def Main(): subprocess.Popen('explorer %s' % OUTPUT_FOLDER.replace('/', '\\')) opts = ParseArgs() loglevel = logging.DEBUG if opts.debug else logging.INFO logging.basicConfig(level=loglevel, filename=stdlogutils.GetTimestampedFilename2(APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) resmapper = fsdauthoringutils.GraphicsCache(devenv.EVEROOT) invmapper = inventory.InventoryMapper(opts.branch) _appsetup.CreateTrinityApp() typeIDs = opts.types if opts.cameraYPR and len(opts.cameraYPR) == 3: cameraAngle = map(float, opts.cameraYPR) else: cameraAngle = None if opts.sunDirection and len(opts.sunDirection) == 3: sunDirection = map(float, opts.sunDirection) else: sunDirection = (-0.4592, -0.4602, 0.6614) tempRenders = [] for typeID in typeIDs: gID = resmapper.GetGraphicIDForTypeID(typeID) sofData = resmapper.GetSOFDataForGraphicID(gID) raceID = invmapper.GetTypeData(typeID)[2] scenePath = photo.GetScenePathByRaceID(raceID) sofDNA = '' if all(sofData): sofDataForType = resmapper.GetSOFDataForTypeID(typeID) sofDNA = CombineSOFDNA(sofAddition=sofDataForType[0], *sofData) graphicFile = resmapper.GetGraphicFileForGraphicID(gID) if not sofDNA and not graphicFile: L.error('Type %s does not have a graphicFile nor SOF data' % typeID) continue sourceFiles = [] for color, suffix in COLORS: outPath = os.path.join(OUTPUT_FOLDER, str(typeID) + '_' + suffix + '.png') L.debug('Rendering %s' % outPath) photo.RenderSpaceObject(outPath=outPath, scenePath=scenePath, objectPath=graphicFile, sofDNA=sofDNA, size=512, bgColor=color, transparent=True, cameraAngle=cameraAngle, sunDirection=sunDirection) sourceFiles.append(outPath) tempRenders.extend(sourceFiles) finalPath = os.path.join(OUTPUT_FOLDER, str(typeID) + u'.png') CreateAlpha(finalPath, sourceFiles) if not opts.keepsource: for filePath in tempRenders: os.remove(filePath) sys.exit(0)
def Main(): opts = ParseOpts() logging.basicConfig(level=logging.INFO, filename=stdlogutils.GetTimestampedFilename2( iconrendering.APPNAME), format=stdlogutils.Fmt.NTLM) streamh = logging.StreamHandler(sys.stdout) streamh.setFormatter(stdlogutils.Fmt.FMT_NTLM) L.addHandler(streamh) L.info('Starting iec verification.') try: knownGood = GetLatestDirectory( os.path.join(opts.rootfolder, opts.searchfolderGood)) except: L.info('Could not find known good directory. Aborting') return compareTo = os.path.join(opts.rootfolder, opts.subfolderCompare) startTime = time.clock() L.info('Analyzing folder structure.') dirsGood, dirsComp, foldersMissing, foldersAdded, foldersRemoved = GetDirectoryInfo( knownGood, compareTo) filesAdded = [] filesRemoved = [] changedFiles = [] sizeChanged = [] for each in dirsComp: if each in foldersMissing: continue L.info('Comparing files in %s', each) dirpathGood, _, filenamesGood = dirsGood[each] dirpathComp, _, filenamesComp = dirsComp[each] missingEither, added, removed = FindMissing(filenamesGood, filenamesComp) filesAdded.extend(map(lambda x: os.path.join(each, x), added)) filesRemoved.extend(map(lambda x: os.path.join(each, x), removed)) for fn in filenamesComp: if fn in added: continue fnGood = os.path.join(dirpathGood, fn) fnCompare = os.path.join(dirpathComp, fn) try: error = GetImgDiffError(fnGood, fnCompare) if error > TOLERANCE: changedFiles.append((os.path.join(each, fn), error)) except imgdiff.SizeMismatch: sizeChanged.append(os.path.join(each, fn)) L.error('Image size changed: %s', os.path.join(each, fn)) endTime = time.clock() L.info('Icon verification finished in %d seconds.' % (endTime - startTime)) changedFiles.sort(key=lambda x: x[1], reverse=True) L.info('A total of %d folders were added', len(foldersAdded)) L.info('A total of %d folders were removed', len(foldersRemoved)) L.info('A total of %d files were added', len(filesAdded)) L.info('A total of %d files were removed', len(filesRemoved)) L.info('A total of %d files have changed', len(changedFiles)) L.info('A total of %d image sizes have changed', len(sizeChanged)) def _writeDumpFile(): dumpFile = os.path.join( opts.rootfolder, 'verificationDump_%s.txt' % datetime.datetime.now().strftime(iconrendering.TIMESTAMP_FORMAT)) f = open(dumpFile, 'w') f.write('Detailed breakdown:\n') WriteDetails('A total of %d folders were added\n', foldersAdded, f) WriteDetails('A total of %d folders were removed\n', foldersRemoved, f) WriteDetails('A total of %d files were added\n', filesAdded, f) WriteDetails('A total of %d files were removed\n', filesRemoved, f) WriteDetails('A total of %d files have changed\n', changedFiles, f) WriteDetails('A total of %d image sizes have changed\n', sizeChanged, f) f.flush() f.close() _writeDumpFile()