def checkStream(self, context, field): root = self.fillStream(context, field) log.debug3("{0} check stream completion ...", field.id, tags=['lock']) upstream = self._upstreams.get(field.id, list()) contexts = [root] while contexts: ctx = contexts.pop(0) if ctx.node not in upstream: continue heap = field.heap(ctx) if not heap: continue heap_size = heap[0].size heap_fill = len(heap) if heap_fill < heap_size: return None log.debug3("{0} - all streams seem ok", field.id, tags=['lock']) return root
def bench_logs(num_pass=30000): print "... bench logging" times = dict() msg = "{0} - {1} - this is a print iteration, please ignore this message" key = 'simple' print "... simple print" start = datetime.now() for i in xrange(num_pass): print msg.format(key, i) times[key] = datetime.now() - start os.environ['DEBUG_LOGFILE'] = '' key = 'log' print "... log print" start = datetime.now() for i in xrange(num_pass): log.info(msg, key, i) times[key] = datetime.now() - start key = 'passed' print "... log ignored" start = datetime.now() for i in xrange(num_pass): log.debug3(msg, key, i) times[key] = datetime.now() - start os.environ['DEBUG_LOGFILE'] = 'C:/work/test.log' key = 'file' print "... log to file" start = datetime.now() for i in xrange(num_pass): log.info(msg, key, i) times[key] = datetime.now() - start print "" print "-" * 40 for k, v in times.iteritems(): print str(k) + ' = ' + str(v)
def canRun(self, context): log.debug3('... {0} Node.canRun', self.id, tags=["lock"]) ret = None for field in self.getInputs(): if not field.stream: continue if not field.hasIncomingLinks(): continue if field.fieldId == "out_path": continue if not field.heap(context): log.debug3('{0} has empty heap', field.id, tags=["lock"]) ret = None break else: log.debug3('{0} has values stacked', field.id, tags=["lock"]) ret = self.checkStream(context, field) if not ret: break logger = log.debug2 if ret else log.debug3 logger('... {0} Node.canRun: {1}', self.id, ret, tags=["lock"]) if ret: print "*" * 80 print "* RUN CONCAT" print "*" * 80 self.dumpHeap(context) return ret
def parseScene(self, context, scene): cls = {"shapes": ["Geom*"], "shaders": ["*BRDF*"], "lights": ["*Light*"], "nodes": ["Node"], "settings": ["*Settings*"], "view": ["RenderView", "Camera*"], "others": ["*"]} order = ["shapes", "shaders", "lights", "nodes", "settings", "view", "others"] fields = dict() plugs = dict() for field in cls.keys(): fields[field] = self.field(field) plugs[field] = list() vrs = scene frame = self.field('frame') vrs.renderer.time = frame.value index = 0 for plugin in vrs.plugins: # name = plugin.getName() plug_cls = plugin.getType() found = False field = None # for field, patterns in cls.iteritems(): for field in order: patterns = cls[field] found = False for pattern in patterns: if fnmatch.fnmatch(plug_cls, pattern): msg = "{0} match {1} : return {2}" log.debug3(msg, plug_cls, pattern, field) found = True break if found: break if not found: msg = "{0} dont match anything : return 'others'" log.debug3(msg, plug_cls, pattern, field) field = "others" plugs[field].append(plugin) for field, plugins in plugs.iteritems(): field = fields.get(field) if (not field) or field.linked: continue if not plugins: field.pushEmpty(context, self) continue num_plugs = len(plugins) index = 0 for plugin in plugins: index += 1 log.debug3("o" * 80, tags=['stream']) log.debug3("{0} - {1} pushing {2} / {3}", context, self.id, index, num_plugs, tags=['stream']) token = Token(plugin, source=self, index=index, size=num_plugs) field.push(context, token)