def isCompItemMissingRenders(compItem): """ Check if renders for a comp item are missing or out of date. Returns (missing, out of date) """ missing = False try: # Get the render info for the comp info = CompSourceInfo(compItem) startFrame = info.firstFrame endFrame = info.lastFrame # If the item is a TrackItem, search for missing files in its source range if isinstance(compItem, hiero.core.TrackItem): startFrame = int(compItem.sourceIn() + info.firstFrame) endFrame = int(compItem.sourceOut() + info.firstFrame) # Iterate over the frame range and check if any files are missing. The + 1 is necessary, because xrange is exclusive at the end of the interval. for frame in xrange(startFrame, endFrame + 1): framePath = info.writePath % frame try: frameModTime = round(filesystem.stat(framePath).st_mtime) except OSError, e: # Check if file doesn't exist if e.errno == errno.ENOENT: missing = True break else: raise except: # Catch all: log, and false will be returned hiero.core.log.exception("isCompItemMissingRenders unexpected error") return missing
def isCompItemMissingRenders(compItem): """ Check if renders for a comp item are missing. """ try: # Get the render info for the comp info = CompSourceInfo(compItem) startFrame = info.firstFrame endFrame = info.lastFrame # If the item is a TrackItem, search for missing files in its source range if isinstance(compItem, hiero.core.TrackItem): startFrame = int(compItem.sourceIn() + info.firstFrame) endFrame = int(compItem.sourceOut() + info.firstFrame) try: # Try for < 10.0v5 compatibility # Get the script modified time. Note rounding, as comparisons to nearest # second are fine for this purpose scriptModTime = round(filesystem.stat(info.nkPath).st_mtime) # Iterate over the frame range and check if any files are missing for frame in xrange(startFrame, endFrame): framePath = info.writePath % frame try: frameModTime = round(filesystem.stat(framePath).st_mtime) if frameModTime < scriptModTime: return True except OSError, e: # Check if file doesn't exist if e.errno == errno.ENOENT: return True else: raise except: # Iterate over the frame range and check if any files are missing for frame in xrange(startFrame, endFrame): framePath = info.writePath % frame if not os.path.exists(framePath): return True except: # Catch all: log, and false will be returned hiero.core.log.exception("isCompItemMissingRenders unexpected error") return False