def GetScrollEntryAlignmentDebug(self, c, h, color): if c.display: display = 'True' else: display = '<color=red>False</color>' if c._alignmentDirty: _alignmentDirty = '<color=red>True</color>' else: _alignmentDirty = 'False' if c._displayDirty: _displayDirty = '<color=red>True</color>' else: _displayDirty = 'False' return uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label= '<color=%s>%s</color><t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s' % (color.GetHex(), c.name, c.left, c.top, c.width, c.height, self.GetAlignAsString(c), display, c.displayX, c.displayY, c.displayWidth, c.displayHeight, _alignmentDirty, _displayDirty), OnMouseEnter=self.OnListentryMouseEnter, OnMouseExit=self.OnListentryMouseExit, OnDblClick=self.OnListentryDblClick, OnClick=self.OnListentryClick, OnGetMenu=self.ListentryGetMenu, cont=c, highlightCont=h)
def GetObjects(self, num=1000000, drill=None, textDrill=None, b=0, e=100): wnd = self.GetWnd() if not wnd or wnd.destroyed: return dict = {} import weakref for object in gc.get_objects(): tp = type(object) if not isinstance(object, weakref.ProxyType): try: tp = object.__class__ except AttributeError: sys.exc_clear() dict[tp] = dict.get(tp, 0) + 1 dict2 = {} for k, v in dict.iteritems(): n = k.__module__ + '.' + k.__name__ dict2[n] = dict2.get(n, 0) + v scrolllist = [] items = dict2.items() items.sort() for tp, inst in items: scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, OnDblClick=self.ClickEntry, instType=tp, label='%s<t>%s' % (tp, util.FmtAmt(inst)))) wnd.sr.scroll.Load(contentList=scrolllist, headers=['type', 'instances'], fixedEntryHeight=18)
def _GetAvailableActions(self): contentList = [] actionTreeInstance = self.zactionClient.GetActionTree( ).GetTreeInstanceByEntID(self.selectedEntID) if not actionTreeInstance: return contentList availableActions = actionTreeInstance.GetAvailableActionsList( self.zactionClient.GetClientProperties()) for actionID, isSibling, isActive, canRequest in availableActions: actionNode = self.zactionClient.GetActionTree().GetTreeNodeByID( actionID) actionLabel = '%s(%d)' % (actionNode.name, actionNode.ID) data = { 'text': actionLabel, 'label': actionLabel, 'id': actionID, 'actionID': actionID, 'isActive': isActive, 'isSibling': isSibling, 'canRequest': canRequest, 'showicon': 'hide', 'showlen': False, 'openByDefault': False, 'hideNoItem': True, 'disableToggle': True, 'OnClick': self.SelectDoAction, 'OnDblClick': self.SelectDoAction } contentList.append(uicontrols.ScrollEntryNode(**data)) contentList.sort(lambda x, y: cmp(x.text, y.text)) return contentList
def _UpdateScroll(self): if self.isPaused: return wndAbove = uiutil.GetWindowAbove(uicore.uilib.mouseOver) if isinstance(wndAbove, form.UIEventListener) and uicore.uilib.rightbtn: return scrolllist = [] lastTime = None for time, event in self.events[:self.showMax]: if lastTime == time: time = '' else: lastTime = time label = time + '<t>' + self.GetScrollLabel(event) scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label=label, fontsize=14, event=event, OnGetMenu=self.GetScrollEntryMenu)) self.scroll.Load(contentList=scrolllist, headers=self.SCROLL_HEADERS, ignoreSort=True)
def GetScrollEntryNormal(self, c, h, color): try: cCol = c.color.GetRGBA() except: cCol = '-' if c.destroyed: color.SetRGB(0.5, 0.5, 0.5, 0.3) return uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label= '<color=%s>%s</color><t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s' % (color.GetHex(), c.name, c.left, c.top, c.width, c.height, self.GetAlignAsString(c), self.GetStateAsString(c), getattr(c, 'padLeft', '-'), getattr(c, 'padTop', '-'), getattr(c, 'padRight', '-'), getattr(c, 'padBottom', '-'), getattr(c, 'opacity', '-'), cCol, c.__class__.__name__, getattr(c.__renderObject__, '__name__', '-')), OnMouseEnter=self.OnListentryMouseEnter, OnMouseExit=self.OnListentryMouseExit, OnDblClick=self.OnListentryDblClick, OnClick=self.OnListentryClick, OnGetMenu=self.ListentryGetMenu, cont=c, highlightCont=h, hint=self._GetLabelRecurs('', c))
def _GetCombatLogLines(self, bForceUpdate=False): serverLineNumber = self.zactionLoggerSvc.GetLineNumber() serverComboElementVersion = self.zactionLoggerSvc.GetComboElementVersion( ) if bForceUpdate or serverLineNumber != self.lineNumber: self.lineNumber = serverLineNumber contentList = [] logLines = self.zactionLoggerSvc.GetCombatLog( self.selectedEntity, self.selectedCategory) for entry in logLines: subbedChat, entID, logCategory = entry data = { 'label': subbedChat, 'hideNoItem': True, 'OnDblClick': self._FilterSelectedEntity, 'entID': entID, 'logCategory': logCategory } contentList.append(uicontrols.ScrollEntryNode(**data)) contentList.reverse() self.combatLogLines.LoadContent(contentList=contentList, keepPosition=True) if bForceUpdate or serverComboElementVersion != self.comboElementVersion: self.comboElementVersion = serverComboElementVersion self._UpdateComboBoxes()
def _updateList(): while uicontrols.Window.IsOpen(windowID=winID): contentList, layout, headers = contentFunction() scrolllist = [] for entry in contentList: label = layout % entry scrolllist.append(uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label=label)) scroll.Load(contentList=scrolllist, headers=headers, fixedEntryHeight=18) blue.synchro.SleepWallclock(updateFreq)
def _UpdateIgnoreScroll(self): scrolllist = [] for id, name in self.ignoreEvents.iteritems(): scrolllist.append( uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label=name, id=id, fontsize=14, OnMouseDown=self.RemoveEventFromIgnore)) self.ignoreScroll.Load(contentList=scrolllist)
def _UpdateScroll(self): blue.synchro.SleepWallclock(250) if self.destroyed: return scrolllist = [] scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label='Ancestors', fontsize=18, showline=True)) for i, (c, h, color) in enumerate(self.ancestorConts): scrolllist.append(self.GetScrollEntry(c, h, color)) scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label='Selected', fontsize=18, showline=True)) scrolllist.append(self.GetScrollEntry(*self.selectedCont)) scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label='Children', fontsize=18, showline=True)) for i, (c, h, color) in enumerate(self.childrenConts): scrolllist.append(self.GetScrollEntry(c, h, color)) if self.backgroundConts: scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label='Background', fontsize=18, showline=True)) for i, (c, h, color) in enumerate(self.backgroundConts): scrolllist.append(self.GetScrollEntry(c, h, color)) self.scroll.Load(contentList=scrolllist, headers=self.GetScrollHeaders(), ignoreSort=True)
def PopulateMainQueueScroll(self, *args): self.queue = remotefilecache.get_queue() contentList = [] index = 1 for item in self.queue: label = '%d<t>%s<t>%d' % (index, item.key, len(item.fileset)) listEntry = uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, id=id, label=label) contentList.append(listEntry) index += 1 self.mainQueue.Load(contentList=contentList, headers=['#', 'Key', 'Files'], noContentHint='Queue is empty') if self.queue: self.PopulateSubQueue(self.queue[0])
def PopulateSubQueue(self, item): itemList = list(item.fileset) if len(itemList) > 50: itemList = itemList[0:49] itemList.append('...') contentList = [] index = 1 for each in itemList: label = '%d<t>%s' % (index, each) listEntry = uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, id=id, label=label) contentList.append(listEntry) index += 1 self.subQueue.Load(contentList=contentList, headers=['#', 'Resource file'], noContentHint='Queue is empty')
def UpdateOutstanding(self): wnd = self.GetWnd() if not wnd or wnd.destroyed: return scrolllist = [] for ct in base.outstandingCallTimers: method = ct[0] t = ct[1] label = '%s<t>%s<t>%s' % (method, util.FmtDate( t, 'nl'), util.FmtTime(blue.os.GetWallclockTimeNow() - t)) scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label=label)) wnd.sr.scroll.Load(contentList=scrolllist, headers=['method', 'time', 'dt'])
def UpdateTimers(self): wnd = self.GetWnd() if not wnd or wnd.destroyed: return scrolllist = [] for timer in base.AutoTimer.autoTimers.iterkeys(): label = str(timer.method) label = label[1:] label = label.split(' ') label = ' '.join(label[:3]) scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label='%s<t>%s<t>%s' % (label, timer.interval, timer.run))) wnd.sr.scroll.Load(contentList=scrolllist, headers=['method', 'interval', 'run'], fixedEntryHeight=18)
def UpdateROT(self, force=False): wnd = self.GetWnd() if wnd: try: rot = blue.classes.LiveCount() if not getattr(self, 'rotinited', 0) or force: scrolllist = [] for k, v in rot.iteritems(): scrolllist.append( uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, totalDelta=0, typeName=k, peakValue=v, lastValue=v, label='%s<t>%s<t>%s<t>%s' % (k, 0, v, v))) wnd.sr.scroll.Load( contentList=scrolllist, headers=['type', 'delta', 'instances', 'peak'], fixedEntryHeight=18) self.showing = 'rot' self.rotinited = 1 return for entry in wnd.sr.scroll.GetNodes(): v = rot[entry.typeName] d = v - entry.lastValue td = d + entry.totalDelta entry.totalDelta = td peak = self.maxPeaks.get(entry.typeName, -1) p = max(peak, v) self.maxPeaks[entry.typeName] = p c = ['<color=0xff00ff00>', '<color=0xffff0000>'][td > 0] entry.label = '%s<t>%s%s<color=0xffffffff><t>%s<t>%s' % ( entry.typeName, c, td, v, p) if entry.panel: entry.panel.sr.label.text = entry.label entry.lastValue = v wnd.sr.scroll.RefreshSort() except: self.timer = None sys.exc_clear()
def UpdateMethodCalls(self): wnd = self.GetWnd() if not wnd or wnd.destroyed: return scrolllist = [] history = list(base.methodCallHistory) history.reverse() for ct in history[:100]: method = ct[0] t = ct[1] label = '%s<t>%s<t>%s' % (method, util.FmtDate( t, 'nl'), ct[2] / const.MSEC) scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label=label)) wnd.sr.scroll.Load(contentList=scrolllist, headers=['method', 'time', 'ms']) wnd.sr.scroll.sr.notSortableColumns = ['method']
def PopulateScroll(self, *args): totalWarnings = 0 contentList = [] for ctx, v in blue.pyos.taskletTimer.taskletWarnings.iteritems(): maxValue, count = v label = '%d<t>%d<t>%s' % (maxValue, count, ctx) listEntry = uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, id=id, maxValue=maxValue, count=count, context=ctx, label=label) contentList.append(listEntry) totalWarnings += count self.scroll.Load(contentList=contentList, headers=['Max value', 'Count', 'Context'], noContentHint='No Data available') self.countLabel.text = '%d warnings' % totalWarnings
def ClickEntry(self, entry, *args): typeName = entry.sr.node.instType.__name__ inst = gc.get_objects() alldict = {} for object in inst: s = type(object) alldict.setdefault(s, []).append(object) attrs = { 'BlueWrapper': ['__typename__', '__guid__'], 'instance': ['__class__', '__guid__'], 'class': ['__guid__', '__class__', '__repr__'] } attr = attrs.get(typeName, None) if attr is None: return dict = {} for i in alldict[entry.sr.node.instType]: stringval = '' for a in attr: stringval += str(getattr(i, a, None))[:24] + '<t>' dict.setdefault(stringval, []).append(i) scrolllist = [] for tp, inst in dict.iteritems(): if tp == 'None<t>' * len(attr): continue scrolllist.append( uicontrols.ScrollEntryNode(decoClass=uicontrols.SE_GenericCore, label='%s%s' % (tp, util.FmtAmt(len(inst))))) wnd = self.GetWnd() if not wnd or wnd.destroyed: return wnd.wnd.sr.scroll.Load(contentList=scrolllist, headers=attr + ['instances'], fixedEntryHeight=18)
def DoUpdateLogs(self, loggingToWindow=True): wnd = self.GetWnd() entries = blue.logInMemory.GetEntries() if entries: logsToFile = [] scrolllist = [] for i, e in enumerate(entries): if e == self.lastLogEntry: break s = LOGTYPE_MAPPING.get(e[2], ('Unknown', '0xffeeeeee')) lineno = 0 for line in e[4].split('\n'): label = '%s<t>%s<t>%s::%s<t><color=%s>%s</color><t>%s' % ( str(e[3] + lineno)[-15:], util.FmtDate(e[3], 'nl'), e[0], e[1], s[1], s[0], line.replace('<', '<')) scrolllist.append( uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label=label)) lineno += 1 if self.logSaveHandle: txt = '%s\t%s::%s\t%s\t%s\n' % (util.FmtDate( e[3], 'nl'), e[0], e[1], s[0], e[4]) logsToFile.append(txt) if self.logSaveHandle: logsToFile.reverse() for l in logsToFile: self.logSaveHandle.Write(l) self.lastLogEntry = entries[0] if scrolllist and loggingToWindow: wnd.sr.scroll.AddEntries(-1, scrolllist) if loggingToWindow: maxEntries = blue.logInMemory.capacity if len(wnd.sr.scroll.GetNodes()) > maxEntries: wnd.sr.scroll.RemoveEntries( wnd.sr.scroll.GetNodes()[:-maxEntries])
def _GetAllActions(self): contentList = [] allActions = self.zactionClient.GetActionTree().GetAllTreeNodesList() for actionNode in allActions: if actionNode.actionType != const.ztree.NODE_FOLDER: actionLabel = '%s(%d)' % (actionNode.name, actionNode.ID) data = { 'text': actionLabel, 'label': actionLabel, 'id': actionNode.ID, 'actionID': actionNode.ID, 'showicon': 'hide', 'showlen': False, 'openByDefault': False, 'hideNoItem': True, 'disableToggle': True, 'OnClick': self.SelectForceAction, 'OnDblClick': self.SelectForceAction } contentList.append(uicontrols.ScrollEntryNode(**data)) contentList.sort(lambda x, y: cmp(x.text, y.text)) return contentList
def UpdateTable(self): layout = '%s<t>%s<t>%s<t>%s<t>%s<t>%s' headers = [ 'distance (m)', 'itemID', 'Type Name', 'Group Name', 'Explosion Bucket ID', 'Selected Explosion' ] content = [] ballpark = sm.GetService('michelle').GetBallpark() balls = ballpark.GetBallsInRange(session.shipid, SEARCH_DISTANCE) selectedEntries = [] for ballID in balls: ball = sm.GetService('michelle').GetBall(ballID) if not hasattr(ball, 'typeData') or getattr( ball, 'exploded', False): continue typeID = ball.typeData['typeID'] explosionBucketID = GetExplosionBucketIDByTypeID(typeID) if explosionBucketID is None: continue typeName = evetypes.GetName(typeID) groupName = evetypes.GetGroupName(typeID) explosionRes = 'Random' dist = util.FmtAmt(ballpark.DistanceBetween( session.shipid, ballID)) info = (dist, ballID, typeName, groupName, explosionBucketID, explosionRes) label = layout % info entry = uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label=label) if ballID in self.selectedBallsToExplosionBucketID: selectedEntries.append(entry) content.append(entry) self.scroll.Load(contentList=content, headers=headers, fixedEntryHeight=18) self.scroll.SelectNodes(selectedEntries)
def OnListEntryClicked(self, listEntry): node = listEntry.sr.node contentList = [] entryNo = 1 for each in node.callstack: filename, line, function_name, code = each label = '%d<t>%s<t>%d<t>%s<t>%s' % (entryNo, filename, line, function_name, code) listEntry = uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, id=id, entryNo=entryNo, filename=filename, line=line, function_name=function_name, code=code, label=label) contentList.append(listEntry) entryNo += 1 self.callstack.Load( contentList=contentList, headers=['Entry', 'File name', 'Line', 'Function name', 'Code'], noContentHint='No Data available')
def PopulateScroll(self, *args): contentList = [] for t in bluepy.tasklets.keys(): if not t.alive: continue callstack = traceback.extract_stack(t.frame) ctx = getattr(t, 'context', '(unknown)') runtime = getattr(t, 'runTime', 0) label = '%d<t>%f<t>%s' % (t.tasklet_id, runtime, ctx) listEntry = uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, id=id, taskletId=t.tasklet_id, context=ctx, callstack=callstack, runTime=runtime, label=label, OnClick=self.OnListEntryClicked) contentList.append(listEntry) self.scroll.Load(contentList=contentList, headers=['ID', 'Runtime', 'Context'], noContentHint='No Data available') self.countLabel.text = '%d tasklets' % len(contentList)