def SetCurrentRLMonth(self, selectToday=True, *args): now = blue.os.GetWallclockTime() year, month, wd, monthday, hour, min, sec, ms = util.GetTimeParts(now) self.yearMonthInView = (year, month) self.SetMonth(year, month) if selectToday: self.CrawlForAndSetMonthday(monthday)
def ChangeMonth(self, direction=1, selectDay=1, *args): year, month = self.yearMonthInView if direction == -1 and self.disbleBack or direction == 1 and self.disbleForward: return False year, month = sm.GetService('calendar').GetBrowsedMonth( direction, year, month) self.yearMonthInView = (year, month) self.SetMonth(year, month) now = blue.os.GetWallclockTime() rlYear, rlMonth, wd, day, hour, min, sec, ms = util.GetTimeParts(now) nowNumMonths = rlYear * 12 + rlMonth thenNumMonths = year * 12 + month difference = thenNumMonths - nowNumMonths self.disbleForward = 0 self.disbleBack = 0 if direction == 1 and difference >= const.calendarViewRangeInMonths: self.disbleForward = 1 elif direction == -1 and -difference >= const.calendarViewRangeInMonths: self.disbleBack = 1 self.ChangeBrowseDisplay(self.sr.backBtn, disable=self.disbleBack) self.ChangeBrowseDisplay(self.sr.fwdBtn, disable=self.disbleForward) self.selectedDay = self.CrawlForValidDay(self.selectedDay, direction, 'day') if selectDay: self.SelectDay() return True
def MakeExpiry(self, d, h, m, s): dayname = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] monthname = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] year, month, weekday, day, hour, minute, second, ms = util.GetTimeParts(blue.os.GetWallclockTime(), utc=True) args = (dayname[weekday], day + d, monthname[month - 1], year, hour + h, minute + m, second + s) return '%s, %d %s %d %.2d:%.2d:%.2d GMT' % args
def FmtEventLogDate(date): """ Replicates the functionality in FmtDateEng for the specific formatting of the eventLog timestamp format in an optimized way since this will be called frequently. The return value is in the form YYYY.mm.dd HH:mm:ss.ms """ year, month, wd, day, hour, minute, sec, ms = util.GetTimeParts(date) return '%04d.%02d.%02d %02d:%02d:%02d.%03d' % (year, month, day, hour, minute, sec, ms)
def IsTooFarInFuture(self, year, month): now = blue.os.GetWallclockTime() rlYear, rlMonth, wd, day, hour, min, sec, ms = util.GetTimeParts(now) nowNumMonths = rlYear * 12 + rlMonth thenNumMonths = year * 12 + month difference = thenNumMonths - nowNumMonths if difference > const.calendarViewRangeInMonths: return True return False
def GetHeapGraph(self): if self.GetGraphType() != GRAPH_HEAP: return fontSize = 7.5 fontFace = 'arial.ttc' wnd = self.GetWnd() wnd.sr.graph.Flush() w, h = wnd.sr.graph.absoluteRight - wnd.sr.graph.absoluteLeft, wnd.sr.graph.absoluteBottom - wnd.sr.graph.absoluteTop width = w height = h c = chart.XYChart(width, height, bgColor=chart.Transparent) c.setColors(chart.whiteOnBlackPalette) c.setBackground(chart.Transparent) c.setTransparentColor(-1) c.setAntiAlias(1, 1) offsX = 60 offsY = 17 canvasWidth = width - 1 * offsX - 50 canvasHeight = height - offsY * 2.5 plotArea = c.setPlotArea(offsX, offsY, canvasWidth, canvasHeight, 1711276032, -1, -1, 5592405) import random c.addLegend(85, 18, 0, fontFace, fontSize).setBackground(chart.Transparent) random.seed(1001) for k, lst in self.heaphistory.iteritems(): name = 'monitor_setting_heap_%s' % k if not settings.user.ui.Get(name, 1): continue memData = [] timeData = [] for t, n in lst: memData.append(n / 1024 / 1024) year, month, wd, day, hour, minutes, sec, ms = util.GetTimeParts( t) timeData.append( chart.chartTime(year, month, day, hour, minutes, sec)) lines = c.addLineLayer() l = (random.randint(0, 15), random.randint(0, 255), random.randint(0, 255)) l = '0x%X%X%Xee' % (l[0], l[1], l[2]) lines.addDataSet(memData, int(l, 16), '#%s' % k).setLineWidth(1) lines.setXData(timeData) c.xAxis().setDateScale3('{value|hh:nn}') leftAxis = c.yAxis() leftAxis.setTitle('Heap Size (MB)') buf = c.makeChart2(chart.PNG) hostBitmap = trinity.Tr2HostBitmap(w, h, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM) hostBitmap.LoadFromPngInMemory(buf) linegr = uicls.Sprite(parent=wnd.sr.graph, align=uiconst.TOALL) linegr.GetMenu = self.GetHeapGraphMenu linegr.texture.atlasTexture = uicore.uilib.CreateTexture(width, height) linegr.texture.atlasTexture.CopyFromHostBitmap(hostBitmap)
def CurrentTimeString(): year, month, weekday, day, hour, minute, second, ms = util.GetTimeParts(blue.os.GetWallclockTime()) line = '%d/%d/%d %d:%d:%d.%d' % (month, day, year, hour, minute, second, ms) return line
def CurrentTimeString(): """ returns a string which should be used as a parameter in the flush call the format is: 7/26/2002 14:58:51.15 Flush will append " %d" where d is the Value() of the counter """ year, month, weekday, day, hour, minute, second, ms = util.GetTimeParts( blue.os.GetWallclockTime()) line = '%d/%d/%d %d:%d:%d.%d' % (month, day, year, hour, minute, second, ms) return line
def IsInPast(self, year, month, monthday, hour=0, min=0, allowToday=0, *args): now = blue.os.GetWallclockTime() if allowToday: cyear, cmonth, cwd, cday, chour, cmin, csec, cms = util.GetTimeParts( now) now = blue.os.GetTimeFromParts(cyear, cmonth, cday, 0, 0, 0, 0) thisDay = blue.os.GetTimeFromParts(year, month, monthday, hour, min, 0, 0) return self.IsInPastFromBlueTime(thisDay, now)
def ShowAppropriateInputField(self): currentProperty = self.comboProperty.GetValue() requestedControlType = self.controlsByProperty[currentProperty] currentControlType = None if self.propertyControls.has_key('current'): currentControlType = self.propertyControls['current'] if currentControlType == requestedControlType: return requestedControl = None if self.propertyControls.has_key(requestedControlType): requestedControl = self.propertyControls[requestedControlType] elif requestedControlType == 'role_picker': optionsList = [] for role in self.roles: if role.roleID in self.locationalRoles: continue optionsList.append([role.shortDescription, role.roleID]) requestedControl = uicontrols.Combo(label='', parent=self.wndInputFieldArea, options=optionsList, name=requestedControlType, width=146, pos=(const.defaultPadding, 0, 0, 0), align=uiconst.TOLEFT) elif requestedControlType == 'title_picker': optionsList = [] for title in self.titles.itervalues(): optionsList.append([title.titleName, title.titleID]) requestedControl = uicontrols.Combo(label='', parent=self.wndInputFieldArea, options=optionsList, name=requestedControlType, width=146, pos=(const.defaultPadding, 0, 0, 0), align=uiconst.TOLEFT) elif requestedControlType == 'role_picker_locational': optionsList = [] for role in self.roles: if role.roleID not in self.locationalRoles: continue optionsList.append([role.shortDescription, role.roleID]) requestedControl = uicontrols.Combo(label='', parent=self.wndInputFieldArea, options=optionsList, name=requestedControlType, width=146, pos=(const.defaultPadding, 0, 0, 0), align=uiconst.TOLEFT) elif requestedControlType == 'location_picker': bases = [('-', None)] rows = self.offices if rows and len(rows): for row in rows: bases.append( (cfg.evelocations.Get(row.stationID).locationName, row.stationID)) requestedControl = uicontrols.Combo(label='', parent=self.wndInputFieldArea, options=bases, name=requestedControlType, width=146, pos=(const.defaultPadding, 0, 0, 0), align=uiconst.TOLEFT) elif requestedControlType == 'date_picker': nowSecs = blue.os.GetWallclockTime() year, month, wd, day, hour, min, sec, ms = util.GetTimeParts( nowSecs) now = [year, month, day] requestedControl = uix.GetDatePicker(self.wndInputFieldArea, setval=now, left=6, top=-2, idx=None) elif requestedControlType == 'edit_control': control = uicontrols.SinglelineEdit(name=requestedControlType, parent=self.wndInputFieldArea, width=146, left=const.defaultPadding, align=uiconst.TOLEFT, maxLength=37) requestedControl = control else: raise RuntimeError('UnexpectedControlTypeRequested') if currentControlType is not None and self.propertyControls.has_key( currentControlType): currentControl = self.propertyControls[currentControlType] currentControl.state = uiconst.UI_HIDDEN if requestedControl is None: raise RuntimeError('FailedToCreateControlTypeRequested') requestedControl.state = uiconst.UI_NORMAL self.propertyControls[requestedControlType] = requestedControl self.propertyControls['current'] = requestedControlType
def Setup(self): sm.RegisterNotify(self) now = blue.os.GetWallclockTime() year, month, wd, day, hour, min, sec, ms = util.GetTimeParts(now) self.today = (year, month, day) self.calendar = calendar.Calendar() self.sr.monthTextCont = uicls.Container(name='monthTextCont', parent=self, align=uiconst.TOTOP, pos=(0, 10, 0, 30)) self.sr.gridCont = uicls.Container(name='gridCont', parent=self, align=uiconst.TOALL, pos=(0, 0, 0, const.defaultPadding)) uicls.Frame(parent=self.sr.gridCont, name='gridContFrame', state=uiconst.UI_DISABLED, color=(1.0, 1.0, 1.0, 0.25), pos=(-const.defaultPadding, 0, -const.defaultPadding, -const.defaultPadding)) self.InsertBrowseControls() boxWidth = boxHeight = 30 self.allHeaderBoxes = [] self.allDayBoxes = [] self.allDayBoxesByRows = {} row = uicls.Container(name='row', parent=self.sr.gridCont, align=uiconst.TOTOP, pos=(0, 0, 0, self.headerHeight)) for j in xrange(0, const.calendarNumDaysInWeek): box = uicls.CalendarHeader( name='box', parent=row, align=uiconst.TOLEFT, pos=(0, 0, boxWidth, 0), padding=(self.dayPadding, self.dayPadding, self.dayPadding, self.dayPadding)) self.allHeaderBoxes.append(box) setattr(self.sr, '%s_%s' % (0, j), box) row = None for i in xrange(1, NUM_DAYROWS + 1): row = uicls.Container(name='row', parent=self.sr.gridCont, align=uiconst.TOTOP, pos=(0, 0, 0, boxHeight)) self.allDayRows[i] = row daysInRow = [] box = None for j in xrange(0, const.calendarNumDaysInWeek): configname = '%s_%s' % (i, j) box = self.GetDay(row, boxWidth, configname) self.allDayBoxes.append(box) daysInRow.append(box) setattr(self.sr, configname, box) if box is not None: box.SetAlign(uiconst.TOALL) box.width = 0 self.allDayBoxesByRows[i] = daysInRow if row is not None: row.SetAlign(uiconst.TOALL) row.height = 0 self.SetSizes() self.sr.gridCont._OnSizeChange_NoBlock = self.OnGridContainerSize
def GetGraph(self): isPerf = False if self.GetGraphType() == GRAPH_PERFORMANCE: isPerf = True fontSize = 7.5 fontFace = 'arial.ttc' wnd = self.GetWnd() wnd.sr.graph.Flush() w, h = wnd.sr.graph.absoluteRight - wnd.sr.graph.absoluteLeft, wnd.sr.graph.absoluteBottom - wnd.sr.graph.absoluteTop minutes = settings.user.ui.Get('monitor_setting_memory_time', 60) trend = blue.pyos.cpuUsage[-minutes * 60 / 10:] memCounters = {} perfCounters = {} mega = 1.0 / 1024.0 / 1024.0 timeData = [] memData = [] pymemData = [] bluememData = [] othermemData = [] workingsetData = [] ppsData = [] fpsData = [] threadCpuData = [] procCpuData = [] lastT = lastpf = 0 t1 = 0 if len(trend) > 1: t, cpu, mem, sched = trend[0] lastT = t lastpf = mem[-1] t1 = trend[0][0] benice = blue.pyos.BeNice for t, cpu, mem, sched in trend: benice() elap = t - t1 t1 = t mem, pymem, workingset, pagefaults, bluemem = mem fps, nr_1, ny, ns, dur, nr_2 = sched fpsData.append(fps) memData.append(mem * mega) pymemData.append(pymem * mega) bluememData.append(bluemem * mega) othermem = (mem - bluemem) * mega if othermem < 0: othermem = 0 othermemData.append(othermem) workingsetData.append(workingset * mega) thread_u, proc_u, kernel_u, process_kernel_u = cpu if elap: thread_cpupct = thread_u / float(elap) * 100.0 proc_cpupct = proc_u / float(elap) * 100.0 else: thread_cpupct = proc_cpupct = 0.0 threadCpuData.append(thread_cpupct) procCpuData.append(proc_cpupct) dt = t - lastT lastT = t pf = pagefaults - lastpf lastpf = pagefaults pps = pf / (dt * 1e-07) if dt else 0 ppsData.append(pps) year, month, wd, day, hour, minutes, sec, ms = util.GetTimeParts(t) timeData.append( chart.chartTime(year, month, day, hour, minutes, sec)) if len(ppsData) > 1: ppsData[0] = ppsData[1] memCounters['blue_memory'] = (False, bluememData, 3377390, 1, False) memCounters['other_memory'] = (False, othermemData, 16776960, 1, False) memCounters['python_memory'] = (False, pymemData, 65280, 1, False) memCounters['total_memory'] = (False, memData, 16711680, 2, False) memCounters['working_set'] = (False, workingsetData, 65535, 1, False) memCounters['thread_cpu'] = (True, threadCpuData, 6749952, 1, True) memCounters['fps'] = (True, fpsData, 16711680, 1, False) width = w height = h c = chart.XYChart(width, height, bgColor=chart.Transparent) c.setColors(chart.whiteOnBlackPalette) c.setBackground(chart.Transparent) c.setTransparentColor(-1) c.setAntiAlias(1, 1) offsX = 60 offsY = 17 canvasWidth = width - 1 * offsX - 50 canvasHeight = height - offsY * 2.5 plotArea = c.setPlotArea(offsX, offsY, canvasWidth, canvasHeight, 1711276032, -1, -1, 5592405) c.addLegend(85, 18, 0, fontFace, fontSize).setBackground(chart.Transparent) if len(timeData) > 1: c.xAxis().setDateScale3('{value|hh:nn}') lines = c.addLineLayer() lines2 = c.addLineLayer2() lines2.setUseYAxis2() leftAxis = c.yAxis() rightAxis = c.yAxis2() if isPerf: leftAxis.setTitle('Frames per second') rightAxis.setTitle('CPU (%)') else: leftAxis.setTitle('Memory (MB)') for i, k in enumerate(memCounters.keys()): if settings.user.ui.Get('monitor_setting_%s' % k, 1): title = k.replace('_', ' ').capitalize() if isPerf == memCounters[k][0]: data = memCounters[k][1] col = memCounters[k][2] lineWidth = memCounters[k][3] if not memCounters[k][4]: l = lines else: l = lines2 l.addDataSet(data, col, title).setLineWidth(lineWidth) lines.setXData(timeData) lines2.setXData(timeData) if trend: pf = trend[-1][2][-1] label = 'Working set: %iMB, Virtual mem: %iMB, Page faults: %s' % ( workingsetData[-1], memData[-1], util.FmtAmt(pf)) c.addText(offsX, 2, label) buf = c.makeChart2(chart.PNG) hostBitmap = trinity.Tr2HostBitmap(w, h, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM) hostBitmap.LoadFromPngInMemory(buf) linegr = uicls.Sprite(parent=wnd.sr.graph, align=uiconst.TOALL) linegr.GetMenu = self.GetGraphMenu linegr.texture.atlasTexture = uicore.uilib.CreateTexture(width, height) linegr.texture.atlasTexture.CopyFromHostBitmap(hostBitmap)
def Load(self, args): sm.GetService('corpui').LoadTop( 'res:/ui/Texture/WindowIcons/biography.png', localization.GetByLabel( 'UI/Corporations/BaseCorporationUI/Auditing')) if not self.sr.Get('inited', 0): self.sr.inited = 1 toppar = uiprimitives.Container(name='options', parent=self, align=uiconst.TOTOP, height=20) self.sr.fwdBtn = uicontrols.Button( parent=toppar, icon='res:/UI/Texture/icons/77_32_41.png', iconSize=20, align=uiconst.BOTTOMRIGHT, left=6, func=self.Browse, args=1, hint=localization.GetByLabel('UI/Browser/Forward')) self.sr.backBtn = uicontrols.Button( parent=toppar, icon='res:/UI/Texture/icons/77_32_42.png', iconSize=20, align=uiconst.BOTTOMRIGHT, left=32, func=self.Browse, args=-1, hint=localization.GetByLabel('UI/Browser/Back')) nowSecs = blue.os.GetWallclockTime() year, month, wd, day, hour, min, sec, ms = util.GetTimeParts( nowSecs + const.DAY) now = [year, month, day] year, month, wd, day, hour, min, sec, ms = util.GetTimeParts( nowSecs - const.WEEK + const.DAY) lastWeek = [year, month, day] fromDate = uix.GetDatePicker(toppar, setval=lastWeek, left=5, top=14, idx=None) self.sr.fromDate = fromDate toDate = uix.GetDatePicker(toppar, setval=now, left=fromDate.left + fromDate.width + 4, top=14, idx=None) self.sr.toDate = toDate toppar.height = toDate.top + toDate.height memberIDs = sm.GetService('corp').GetMemberIDs() if len(memberIDs) < 24: memberlist = [] cfg.eveowners.Prime(memberIDs) for charID in memberIDs: memberlist.append([cfg.eveowners.Get(charID).name, charID]) combo = uicontrols.Combo(label=localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/HaveToFindMember' ), parent=toppar, options=memberlist, name='memberID', select=settings.user.ui.Get( 'memberID', None), callback=self.OnComboChange, width=100, pos=(toDate.left + toDate.width + 4, toDate.top, 0, 0)) self.sr.Set('Member', combo) else: searchMember = uicontrols.SinglelineEdit( name='searchMember', parent=toppar, align=uiconst.TOPLEFT, left=toDate.left + toDate.width + 6, top=toDate.top, width=92, maxLength=37, label=localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/SearcForMember' ), isCharacterField=True) searchMember.OnReturn = self.SearchMember self.sr.searchMember = searchMember self.sr.scroll = uicontrols.Scroll( name='auditing', parent=self, padding=(const.defaultPadding, const.defaultPadding, const.defaultPadding, const.defaultPadding)) self.ShowJournal()
def ShowJournal(self, browse=None): if self.sr.notext: self.sr.scroll.ShowHint(None) if eve.session.corprole & const.corpRoleAuditor != const.corpRoleAuditor: self.sr.notext = 1 self.sr.scroll.Load(contentList=[]) self.sr.scroll.ShowHint( localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/AuditorRoleRequired', auditorMessageID=self.auditorMessageID)) return memberID = None memberIDs = sm.GetService('corp').GetMemberIDs() if len(memberIDs) < 24: memberID = self.sr.Member.GetValue() else: string = self.sr.searchMember.GetValue() if not string: eve.Message( 'CustomInfo', { 'info': localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/HaveToFindMember' ) }) uicore.registry.SetFocus(self.sr.searchMember) return memberID = uix.Search( string.lower(), const.groupCharacter, filterCorpID=eve.session.corpid, searchWndName='corpMemberAuditingJournalSearch') if memberID: self.sr.searchMember.SetValue(cfg.eveowners.Get(memberID).name) if memberID is None: eve.Message( 'CustomInfo', { 'info': localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/HaveToFindMember' ) }) return sm.GetService('loading').Cycle('Loading') fromDate = self.sr.fromDate.GetValue() toDate = self.sr.toDate.GetValue() if fromDate == toDate: toDate = toDate + const.DAY if browse is not None: interval = toDate - fromDate if browse == 1: toDate = toDate + interval fromDate = fromDate + interval else: toDate = toDate - interval fromDate = fromDate - interval year, month, wd, day, hour, min, sec, ms = util.GetTimeParts(fromDate) self.sr.fromDate.ycombo.SetValue(year) self.sr.fromDate.mcombo.SetValue(month) self.sr.fromDate.dcombo.SetValue(day) year, month, wd, day, hour, min, sec, ms = util.GetTimeParts(toDate) self.sr.toDate.ycombo.SetValue(year) self.sr.toDate.mcombo.SetValue(month) self.sr.toDate.dcombo.SetValue(day) scrolllist = [] rowsPerPage = 10 logItemEventRows, crpRoleHistroyRows = sm.RemoteSvc( 'corpmgr').AuditMember(memberID, fromDate, toDate, rowsPerPage) logItems = [] for row in logItemEventRows: logItems.append(row) roleItems = [] for row in crpRoleHistroyRows: roleItems.append(row) logItems.sort(lambda x, y: cmp(y.eventDateTime, x.eventDateTime)) roleItems.sort(lambda x, y: cmp(y.changeTime, x.changeTime)) roleRows = sm.GetService('corp').GetRoles() roles = {} for role in roleRows: roles[role.roleID] = role.shortDescription self.sr.mostRecentItem = None self.sr.oldestItem = None ix = 0 if 0 == len(logItems) and 0 == len(roleItems): self.sr.mostRecentItem = toDate self.sr.oldestItem = fromDate while len(logItems) or len(roleItems): ix += 1 if ix > rowsPerPage: break logItem = None roleItem = None if len(logItems): logItem = logItems[0] if len(roleItems): roleItem = roleItems[0] if logItem is not None and roleItem is not None: if logItem.eventDateTime > roleItem.changeTime: roleItem = None else: logItem = None time = '' action = '' if logItem is not None: del logItems[0] time = util.FmtDate(logItem.eventDateTime, 'ss') if self.sr.mostRecentItem is None: self.sr.mostRecentItem = logItem.eventDateTime if self.sr.oldestItem is None: self.sr.oldestItem = logItem.eventDateTime if self.sr.oldestItem > logItem.eventDateTime: self.sr.oldestItem = logItem.eventDateTime if self.sr.mostRecentItem < logItem.eventDateTime: self.sr.mostRecentItem = logItem.eventDateTime corpName = cfg.eveowners.Get( logItem.corporationID ).name if logItem.corporationID else '' if logItem.eventTypeID == 12: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/CreatedCorporation', corpName=corpName) elif logItem.eventTypeID == 13: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/DeletedCorporation', corpName=corpName) elif logItem.eventTypeID == 14: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/LeftCorporation', corpName=corpName) elif logItem.eventTypeID == 15: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/AppliedForMembershipOfCorporation', corpName=corpName) elif logItem.eventTypeID == 16: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/BecameCEOOfCorporation', corpName=corpName) elif logItem.eventTypeID == 17: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/LeftCEOPositionOfCorporation', corpName=corpName) elif logItem.eventTypeID == 44: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/JoinedCorporation', corpName=corpName) else: action = ` logItem ` if roleItem is not None: del roleItems[0] time = util.FmtDate(roleItem.changeTime, 'ss') if self.sr.mostRecentItem is None: self.sr.mostRecentItem = roleItem.changeTime if self.sr.oldestItem is None: self.sr.oldestItem = roleItem.changeTime if self.sr.oldestItem > roleItem.changeTime: self.sr.oldestItem = roleItem.changeTime if self.sr.mostRecentItem < roleItem.changeTime: self.sr.mostRecentItem = roleItem.changeTime rolesBefore = [] rolesAfter = [] for roleID in roles.iterkeys(): if roleItem.oldRoles & roleID == roleID: rolesBefore.append(roleID) if roleItem.newRoles & roleID == roleID: rolesAfter.append(roleID) added = [] removed = [] kept = [] for roleID in roles.iterkeys(): if roleID in rolesBefore: if roleID in rolesAfter: kept.append(roleID) else: removed.append(roleID) elif roleID in rolesAfter: added.append(roleID) issuerID = roleItem.issuerID if issuerID == -1: issuerID = const.ownerCONCORD actionOwner = cfg.eveowners.GetIfExists(issuerID) addedRoleNames = [roles[roleID] for roleID in added] removedRoleNames = [roles[roleID] for roleID in removed] keptRoleNames = [roles[roleID] for roleID in kept] cerberizedAddedRoleNames = localization.formatters.FormatGenericList( addedRoleNames) cerberizedRemovedRoleNames = localization.formatters.FormatGenericList( removedRoleNames) cerberizedKeptRoleNames = localization.formatters.FormatGenericList( keptRoleNames) rolesAddedLabel = '' rolesRemovedLabel = '' rolesKeptLabel = '' if len(addedRoleNames) > 0: rolesAddedLabel = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/RolesAdded', listOfAddedRoles=cerberizedAddedRoleNames) if len(removedRoleNames) > 0: rolesRemovedLabel = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/RolesRemoved', listOfRemovedRoles=cerberizedRemovedRoleNames) if len(keptRoleNames) > 0: rolesKeptLabel = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/RolesKept', listOfKeptRoles=cerberizedKeptRoleNames) summaryLabel = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/SummaryOfChanges', firstListMessage=rolesAddedLabel, secondListMessage=rolesRemovedLabel, thirdListMessage=rolesKeptLabel) unknownIssuer = localization.GetByLabel('UI/Common/Unknown') corpName = cfg.eveowners.Get(roleItem.corporationID).name if actionOwner is None: if roleItem.grantable: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/UnknownCharChangedGrantableRoles', charName=unknownIssuer, changedChar=roleItem.charID, corpName=corpName, whatChanged=summaryLabel) else: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/UnknownCharChangedRoles', charName=unknownIssuer, changedChar=roleItem.charID, corpName=corpName, whatChanged=summaryLabel) elif roleItem.grantable: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/KnownCharChangedGrantableRoles', changingChar=issuerID, changedChar=roleItem.charID, corpName=corpName, whatChanged=summaryLabel) else: action = localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/KnownCharChangedRoles', changingChar=issuerID, changedChar=roleItem.charID, corpName=corpName, whatChanged=summaryLabel) text = '%s<t>%s' % (time, action) scrolllist.append( listentry.Get('Text', { 'text': text, 'line': 1, 'canOpen': 'Action' })) if 0 == len(scrolllist): scrolllist.append( listentry.Get( 'Text', { 'text': localization.GetByLabel('UI/Common/NoDataAvailable'), 'line': 1 })) self.sr.scroll.Load(contentList=scrolllist, headers=[ localization.GetByLabel('UI/Common/Date'), localization.GetByLabel('UI/Common/Action') ]) if not len(scrolllist): self.sr.notext = 1 self.sr.scroll.ShowHint( localization.GetByLabel( 'UI/Corporations/CorporationWindow/Members/Auditing/NoAuditingRecordsFound' )) else: self.sr.notext = 0 self.sr.fwdBtn.state = uiconst.UI_NORMAL self.sr.backBtn.state = uiconst.UI_NORMAL sm.GetService('loading').StopCycle()
def GetChart(self, typeID, days): history = sm.GetService('marketQuote').GetPriceHistory(typeID) timeStamps = [] volData = [] closeData = [] lowData = [] highData = [] for x in history: if x[0] in timeStamps: continue timeStamps.append(x[0]) volData.append(x[4]) closeData.append(x[3]) lowData.append(x[1]) highData.append(x[2]) availableData = len(timeStamps) windowData = settings.user.ui.Get('pricehistorytime', 90) fontFace = uicore.font.GetFontDefault() fontSize = int(8 * uicore.desktop.dpiScaling) trimData = availableData - windowData graphWidth, graphHeight = self.GetSize() graphWidth = int(graphWidth * uicore.desktop.dpiScaling) graphHeight = int(graphHeight * uicore.desktop.dpiScaling) for i in range(len(timeStamps)): stamp = timeStamps[i] year, month, wd, day, hour, min, sec, ms = util.GetTimeParts(stamp) timeStamps[i] = chartTime(year, month, day) isExtrapolated = 0 daysAdded = 0 if trimData < 0: daysAdded = -trimData isExtrapolated = 1 trimData = 0 elif windowData < 30: daysAdded = 5 isExtrapolated = 1 lastStamp = timeStamps[-1] for i in range(daysAdded): timeStamps.append(lastStamp + (i + 1) * 86400) actualData = availableData - trimData if windowData > 90: labels = ArrayMath(timeStamps).trim( trimData).selectStartOfMonth().result() elif windowData >= 10: labels = ArrayMath(timeStamps).trim( trimData).selectStartOfWeek().result() else: labels = ArrayMath(timeStamps).trim( trimData).selectStartOfDay().result() priceWidth = graphWidth priceHeight = graphHeight c = XYChart(priceWidth, priceHeight, Transparent) c.setMonthNames(self.months) palette = whiteOnBlackPalette BORDER_COLOR = 8947848 palette[1] = BORDER_COLOR c.setColors(whiteOnBlackPalette) c.setBackground(Transparent) c.setTransparentColor(-1) c.setAntiAlias(1, 1) if availableData == 0: textBox = c.addText( 20, graphHeight / 5, localization.GetByLabel('UI/PriceHistory/NoDataAvailable'), 'normal', 24) return c.makeChart2(PNG) axis = c.yAxis() axis.setLabelStyle(fontFace, fontSize) axis.setAutoScale(0.1, 0.1, 0.3) axis.setTickDensity(int(40 * uicore.desktop.dpiScaling), -1) axis = c.yAxis2() axis.setLabelFormat('{value|,}') axis.setLabelStyle(fontFace, fontSize) axis.setAutoScale(0.8, 0.0, 1.0) axis.setColors(BORDER_COLOR, Transparent) labelFormatter = localization.GetByLabel( 'UI/PriceHistory/PriceHistoryXAxisFormatter') labelFormatter = labelFormatter.replace('(', '{').replace(')', '}') c.xAxis().setLabels2(labels, labelFormatter) if windowData == 90: c.xAxis().setLabelStep(2) elif windowData == 365: c.xAxis().setLabelStep(2) c.xAxis().setLabelStyle(fontFace, fontSize) c.setXAxisOnTop() paLeft = int(70 * uicore.desktop.dpiScaling) paTop = int(20 * uicore.desktop.dpiScaling) if boot.region == 'optic': paRight = int(130 * uicore.desktop.dpiScaling) else: paRight = int(112 * uicore.desktop.dpiScaling) paBottom = int(40 * uicore.desktop.dpiScaling) c.setPlotArea(paLeft, paTop, priceWidth - paRight, priceHeight - paBottom, 1711276032, -1, -1, 5592405) legendLeft = int(105 * uicore.desktop.dpiScaling) legendTop = int(18 * uicore.desktop.dpiScaling) legend = c.addLegend(legendLeft, legendTop, 0, fontFace, fontSize) legend.setBackground(Transparent) legend.setWidth(priceWidth - 150) trimmedCloseData = ArrayMath(closeData).trim(trimData).result() lst = [] if not settings.user.ui.Get('market_setting_minmax', 1) and not settings.user.ui.Get( 'market_setting_donchian', 1): highData = lowData = closeData hloLayer = c.addHLOCLayer( ArrayMath(highData).trim(trimData).result(), ArrayMath(lowData).trim(trimData).result(), trimmedCloseData, []) hiloCol = mathUtil.LtoI(3724541696L) if settings.user.ui.Get( 'market_setting_minmax', 1) else Transparent hloLayer.getDataSet(0).setDataColor(hiloCol) hloLayer.getDataSet(2).setDataColor(Transparent) hloLayer.getDataSet(3).setDataColor(Transparent) if settings.user.ui.Get('market_setting_movingavg5', 1) or settings.user.ui.Get( 'market_setting_movingavg20', 1): if isExtrapolated: if settings.user.ui.Get('market_setting_movingavg5', 1): avg5 = c.addLineLayer2() lineColor = avg5.xZoneColor( actualData - 1, 16711680, c.dashLineColor(13647936, DashLine)) daysText = uiutil.StripTags(localization.GetByLabel( '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day', value=5), stripOnly=['localized']) label = uiutil.StripTags(localization.GetByLabel( 'UI/PriceHistory/MovingAvg', numDays=daysText), stripOnly=['localized']) avg5.addDataSet( ArrayMath(closeData + 5 * isExtrapolated * closeData[-1:]).movAvg( 5).trim(trimData).result(), lineColor, label) if settings.user.ui.Get('market_setting_movingavg20', 1): avg20 = c.addLineLayer2() lineColor = avg20.xZoneColor( actualData - 1, 6750054, c.dashLineColor(4247616, DashLine)) daysText = uiutil.StripTags(localization.GetByLabel( '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day', value=20), stripOnly=['localized']) label = uiutil.StripTags(localization.GetByLabel( 'UI/PriceHistory/MovingAvg', numDays=daysText), stripOnly=['localized']) avg20.addDataSet( ArrayMath(closeData + 5 * isExtrapolated * closeData[-1:]).movAvg( 20).trim(trimData).result(), lineColor, label) else: if settings.user.ui.Get('market_setting_movingavg5', 1): daysText = uiutil.StripTags(localization.GetByLabel( '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day', value=5), stripOnly=['localized']) avg5 = c.addLineLayer( ArrayMath(closeData).movAvg(5).trim(trimData).result(), 16711680, uiutil.StripTags(localization.GetByLabel( 'UI/PriceHistory/MovingAvg', numDays=daysText), stripOnly=['localized'])) if settings.user.ui.Get('market_setting_movingavg20', 1): daysText = uiutil.StripTags(localization.GetByLabel( '/Carbon/UI/Common/WrittenDateTimeQuantityShort/Day', value=20), stripOnly=['localized']) avg20 = c.addLineLayer( ArrayMath(closeData).movAvg(20).trim( trimData).result(), 6750054, uiutil.StripTags(localization.GetByLabel( 'UI/PriceHistory/MovingAvg', numDays=daysText), stripOnly=['localized'])) if settings.user.ui.Get('market_setting_donchian', 1): upperBand = ArrayMath(highData).movMax(5).trim(trimData).result() lowerBand = ArrayMath(lowData).movMin(5).trim(trimData).result() uLayer = c.addLineLayer( upperBand, mathUtil.LtoI(2868864614L), GetStrippedLabel('UI/PriceHistory/DonchianChannel')) lLayer = c.addLineLayer(lowerBand, mathUtil.LtoI(2868864614L)) c.addInterLineLayer(uLayer.getLine(), lLayer.getLine(), mathUtil.LtoI(3674170982L)) if settings.user.ui.Get('market_setting_mediandayprice', 1): lineLayer = c.addLineLayer( ArrayMath(closeData).trim(trimData).result(), Transparent, GetStrippedLabel('UI/PriceHistory/MedianDayPrice')) lineLayer.getDataSet(0).setDataSymbol(SquareSymbol, 5, fillColor=16776960, edgeColor=3355392) if settings.user.ui.Get('market_setting_volume', 1): barLayer = c.addBarLayer( ArrayMath(volData).trim(trimData).result(), 10092441) barLayer.setBorderColor(Transparent) barLayer.getDataSet(0).setUseYAxis2(1) if windowData <= 30: barLayer.setBarWidth(3) val = max(trimmedCloseData) lf = '{value|2,.}' if val < 10000L: lf = '{value|2,.}' elif val < 1000000L: lf = GetStrippedLabel( 'UI/Market/PriceHistory/YaxisFormattingThousand', fmtString='{={value}/1000|2,.}') elif val < 1000000000L: lf = GetStrippedLabel( 'UI/Market/PriceHistory/YaxisFormattingMillion', fmtString='{={value}/1000000|2,.}') elif val < 1000000000000L: lf = GetStrippedLabel( 'UI/Market/PriceHistory/YaxisFormattingBillion', fmtString='{={value}/1000000000|2,.}') else: lf = GetStrippedLabel( 'UI/Market/PriceHistory/YaxisFormattingTrillion', fmtString='{={value}/1000000000000|2,.}T') c.yAxis().setLabelFormat(lf) c.layout() yAxis = c.yAxis2() ticks = yAxis.getTicks() if len(ticks) > 2: for i in range(3): markValue = ticks[i] label = uiutil.StripTags(util.FmtAmt(markValue, fmt='ss', showFraction=1), stripOnly=['localized']) mark = yAxis.addMark(markValue, Transparent, label, fontFace, fontSize) mark.setMarkColor(Transparent, 16777215, 16777215) return c.makeChart2(PNG)
def FmtEventLogDate(date): year, month, wd, day, hour, minute, sec, ms = util.GetTimeParts(date) return '%04d.%02d.%02d %02d:%02d:%02d.%03d' % (year, month, day, hour, minute, sec, ms)