def OnFileSelected(self, entry): filepath = os.path.join(self.dirpath, entry.sr.node.label + '.xml') self.sr.selectedFileName = entry.sr.node.label profileCheckboxes = [] try: doc = parse(filepath) try: profiles = doc.documentElement.getElementsByTagName('profile') for x in profiles: globalSettings = util.KeyVal() globalSettings.label = x.attributes['name'].value globalSettings.checked = True globalSettings.cfgname = 'profiles' globalSettings.retval = True globalSettings.OnChange = self.OnChange profileCheckboxes.append( listentry.Get('Checkbox', data=globalSettings)) if len( doc.documentElement.getElementsByTagName( 'globalSettings')): globalSettings = util.KeyVal() globalSettings.label = localization.GetByLabel( 'UI/Overview/GlobalOverviewSettings') globalSettings.checked = True globalSettings.cfgname = 'profiles' globalSettings.retval = True globalSettings.OnChange = self.OnChange profileCheckboxes.append( listentry.Get('Checkbox', data=globalSettings)) self.sr.importProfilesBtn.state = uiconst.UI_NORMAL finally: doc.unlink() except Exception as e: profileCheckboxes = [ listentry.Get( 'Generic', { 'label': localization.GetByLabel('UI/Common/Files/FileNotValid') }) ] self.sr.importProfilesBtn.state = uiconst.UI_HIDDEN self.sr.profilesScroll.Load(contentList=profileCheckboxes) self.OnChange()
def GrantAllCertificates(self, certificates): issued = sm.RemoteSvc('certificateMgr').BatchCertificateGrant(certificates) if not issued: return for certificateID in issued: self.myCertificates[certificateID] = util.KeyVal(grantDate=blue.os.GetWallclockTime(), visibilityFlags=0) sm.ScatterEvent('OnCertificateIssued')
def GetVirtualGoodsStoreTemplateData(self): data = util.KeyVal() data.introVideoPath = 'res:/video/cq/LOGO_QUAFE.webm' data.headingText = localization.GetByLabel( 'UI/Station/Holoscreen/VirtualGoods/VisitNeX') data.clickFunc = uicore.cmd.OpenStore data.clickFuncLabel = localization.GetByLabel('UI/Commands/OpenStore') return data
def GetMyCertificates(self, forceUpdate = False): if self.myCertificates is None or forceUpdate: self.myCertificates = {} certs = sm.RemoteSvc('certificateMgr').GetMyCertificates() for cert in certs: self.myCertificates[cert.certificateID] = util.KeyVal(grantDate=cert.grantDate, visibilityFlags=cert.visibilityFlags) return self.myCertificates
def GetOutpostData(self, outpostID): if self.outpostData is not None and blue.os.TimeDiffInMs(self.outpostData.updateTime, blue.os.GetWallclockTime()) > 3600000: return self.outpostData else: allianceSvc = sm.GetService('alliance') corpMgr = moniker.GetCorpStationManagerEx(outpostID) self.outpostData = util.KeyVal(allianceCorpList=set([ corporationID for corporationID in allianceSvc.GetMembers() ]), updateTime=blue.os.GetWallclockTime(), upgradeLevel=corpMgr.GetStationDetails(outpostID).upgradeLevel) return self.outpostData
def GenerateGroupedList(self, lst, ordered = 0, scrollHeaders = []): if ordered == 1: lst.sort(self.GroupItemCompare) rootnode = util.KeyVal() rootnode.groupItems = lst scrolllist = self.GetGroupData(rootnode) _height = 24 self.scroll.Load(contentList=scrolllist, headers=scrollHeaders, noContentHint=self.noContentHint)
def RefreshLists(self, *args): pinListItems = [] for typeID, qty in self.pinContents.iteritems(): lbl = '<t>%s<t>%d' % (evetypes.GetName(typeID), qty) data = util.KeyVal(itemID=None, typeID=typeID, label=lbl, getIcon=1, quantity=qty, OnDropData=self.OnSourceScrollDropData) pinListItems.append(listentry.Get('DraggableItem', data=data)) transferListItems = [] for typeID, qty in self.transferContents.iteritems(): lbl = '<t>%s<t>%d' % (evetypes.GetName(typeID), qty) data = util.KeyVal(itemID=None, typeID=typeID, label=lbl, getIcon=1, quantity=qty, OnDropData=self.OnTransferScrollDropData) transferListItems.append(listentry.Get('DraggableItem', data=data)) self.sr.sourcePinListScroll.Load( contentList=pinListItems, noContentHint=localization.GetByLabel( 'UI/PI/Common/StorehouseIsEmpty'), headers=[ localization.GetByLabel('UI/Common/Type'), localization.GetByLabel('UI/Common/Name'), localization.GetByLabel('UI/Common/Quantity') ]) self.sr.transferListScroll.Load( contentList=transferListItems, noContentHint=localization.GetByLabel('UI/PI/Common/NoItemsFound'), headers=[ localization.GetByLabel('UI/Common/Type'), localization.GetByLabel('UI/Common/Name'), localization.GetByLabel('UI/Common/Quantity') ]) transferVolume = planetCommon.GetCommodityTotalVolume( self.transferContents) self.sr.volumeText.text = localization.GetByLabel( 'UI/PI/Common/VolumeAmount', amount=transferVolume) self.SetNextTransferText() self.SetCooldownTimeText()
def GetSiteKey(self): return util.KeyVal(trusted=0, temporary=0, auto=0, community=0, protocol='', hostname='', path='')
def ShowInfo(self, *args): typeID = self.sr.node.Get('typeID', None) warFactionID = self.sr.node.Get('warFactionID', None) currentRank = self.sr.node.Get('rank', None) if None not in (typeID, warFactionID, currentRank): abstractinfo = util.KeyVal(warFactionID=warFactionID, currentRank=currentRank) sm.GetService('info').ShowInfo(typeID, abstractinfo=abstractinfo)
def GetImportEndpoints(self): endpoints = [] if self.colonyData is not None: for pin in self.colonyData.pins.itervalues(): if not pin.IsCommandCenter() and pin.IsSpaceport(): endpoints.append(util.KeyVal(id=pin.id, capacity=pin.GetCapacity(), capacityUsed=pin.capacityUsed)) return endpoints
def SetCustomsOfficeContent(self): self.customsOfficeContents = {} for item in self.customsOffice.List(const.flagHangar): if item.flagID != const.flagHangar: continue if item.ownerID != session.charid: continue self.customsOfficeContents[item.itemID, item.typeID] = util.KeyVal(itemID=item.itemID, typeID=item.typeID, quantity=item.stacksize, name=cfg.invtypes.Get(item.typeID).name, item=getattr(item, 'item', item))
def GetBlueInfo(numMinutes=None, isYield=True): if numMinutes: trend = blue.pyos.cpuUsage[-numMinutes * 60 / 10:] else: trend = blue.pyos.cpuUsage[:] mega = 1.0 / 1024.0 / 1024.0 ret = util.KeyVal() ret.memData = [] ret.pymemData = [] ret.bluememData = [] ret.othermemData = [] ret.threadCpuData = [] ret.procCpuData = [] ret.threadKerData = [] ret.procKerData = [] ret.timeData = [] ret.latenessData = [] ret.schedData = [] latenessBase = 100000000.0 if len(trend) >= 1: ret.actualmin = int((trend[-1][0] - trend[0][0]) / 10000000.0 / 60.0) t1 = trend[0][0] benice = blue.pyos.BeNice mem = 0 for t, cpu, mem, sched in trend: if isYield: benice() elap = t - t1 t1 = t p_elap = 100.0 / elap if elap else 0.0 mem, pymem, workingset, pagefaults, bluemem = mem ret.memData.append(mem * mega) ret.pymemData.append(pymem * mega) ret.bluememData.append(bluemem * mega) othermem = (mem - pymem - bluemem) * mega if othermem < 0: othermem = 0 ret.othermemData.append(othermem) thread_u, proc_u = cpu[:2] thread_k, proc_k = cpu[2:4] if len(cpu) >= 4 else (0, 0) thread_cpupct = thread_u * p_elap proc_cpupct = proc_u * p_elap thread_kerpct = thread_k * p_elap proc_kerpct = proc_k * p_elap ret.threadCpuData.append(thread_cpupct) ret.procCpuData.append(proc_cpupct) ret.threadKerData.append(thread_kerpct) ret.procKerData.append(proc_kerpct) ret.schedData.append(sched) ret.timeData.append(t) late = 0.0 if elap: late = (elap - latenessBase) / latenessBase * 100 ret.latenessData.append(late) ret.proc_cpupct = proc_cpupct ret.mem = mem return ret
def __PopulateSystemLists(self): """ Utility method to populate the system lists from the flagged-site list on the server/db. """ flaggedSites = [] try: f = blue.ResFile() if f.Open(self.flaggedSitesFile): flaggedSites = cPickle.loads(f.Read()) except: log.LogException('Error reading file from disk') finally: f.Close() try: m = hashlib.md5() m.update(str(flaggedSites)) if m.hexdigest() != sm.RemoteSvc('browserLockdownSvc').GetFlaggedSitesHash(): self.LogInfo('FlaggedSites: Download full list from server') flaggedSites = sm.RemoteSvc('browserLockdownSvc').GetFlaggedSitesList() try: f = blue.ResFile() f.Create(self.flaggedSitesFile) f.Write(cPickle.dumps(flaggedSites)) except: log.LogException('Error writing flaggedSites list to disk') finally: f.Close() except: log.LogException('Error connecting to database') return self.systemLists = util.KeyVal(blacklist=[], bannedInChat=[], whitelist=['about:blank'], community=[], autotrusted=[]) def GetDomainOnly(uStr): if uStr.find(u'//') != -1: uStr = uStr.split(u'//')[1] if uStr.startswith(u'*'): uStr = uStr[1:] if uStr.startswith(u'.'): uStr = uStr[1:] if uStr.endswith(u'/*'): uStr = uStr[:-2] return uStr for flaggedSiteRow in flaggedSites: if flaggedSiteRow['siteFlag'] & self.BLACKLIST_FLAG: self.systemLists.blacklist.append(flaggedSiteRow['siteUrl']) uStr = GetDomainOnly(unicode(flaggedSiteRow['siteUrl'])).strip() if uStr: self.systemLists.bannedInChat.append(uStr) if flaggedSiteRow['siteFlag'] & self.WHITELIST_FLAG: self.systemLists.whitelist.append(flaggedSiteRow['siteUrl']) if flaggedSiteRow['siteFlag'] & self.COMMUNITY_FLAG: self.systemLists.community.append(flaggedSiteRow['siteUrl']) if flaggedSiteRow['siteFlag'] & self.AUTOTRUSTED_FLAG: self.systemLists.autotrusted.append(flaggedSiteRow['siteUrl'])
def ConfigureLocationInfo(self): label = localization.GetByLabel('UI/Neocom/ConfigureWoldInfoText') setting = 'neocomLocationInfo_3' valid = ['nearest', 'sovereignty'] current = sm.GetService('infoPanel').GetLocationInfoSettings() itemMapping = [ util.KeyVal(name='nearest', label='%s / %s' % (localization.GetByLabel('UI/Neocom/Nearest'), localization.GetByLabel('UI/Neocom/DockedIn'))), util.KeyVal(name='sovereignty', label=localization.GetByLabel('UI/Neocom/Sovereignty')) ] format = [{'type': 'text', 'text': label}, {'type': 'push'}] for info in itemMapping: if info.name not in valid: continue format.append({ 'type': 'checkbox', 'setvalue': bool(info.name in current), 'key': info.name, 'label': '_hide', 'required': 1, 'text': info.label, 'onchange': self.ConfigCheckboxChange }) format += [{'type': 'push'}] caption = localization.GetByLabel('UI/Neocom/UpdateLocationSettings') retval = uix.HybridWnd( format, caption, 1, buttons=uiconst.OK, minW=240, minH=100, icon='res:/ui/Texture/WindowIcons/charactersheet.png', unresizeAble=1) if retval: newsettings = [] for k, v in retval.iteritems(): if v == 1: newsettings.append(k) settings.char.windows.Set(setting, newsettings)
def _ReloadScrolls(self): scrolllist = [] for typeID, amount in self.contentsCommodities.iteritems(): data = util.KeyVal() data.label = '<t>%s<t>%s' % (cfg.invtypes.Get(typeID).name, amount) data.typeID = typeID data.itemID = None data.getIcon = True sortBy = amount scrolllist.append((sortBy, listentry.Get('Item', data=data))) scrolllist = uiutil.SortListOfTuples(scrolllist) self.contentsScroll.Load( contentList=scrolllist, noContentHint=localization.GetByLabel( 'UI/PI/Common/StorehouseIsEmpty'), headers=[ '', localization.GetByLabel('UI/PI/Common/Type'), localization.GetByLabel('UI/Common/Quantity') ]) scrolllist = [] for typeID, amount in self.payloadCommodities.iteritems(): data = util.KeyVal() data.label = '<t>%s<t>%s' % (cfg.invtypes.Get(typeID).name, amount) data.typeID = typeID data.itemID = None data.getIcon = True sortBy = amount scrolllist.append((sortBy, listentry.Get('Item', data=data))) scrolllist = uiutil.SortListOfTuples(scrolllist) self.payloadScroll.Load( contentList=scrolllist, noContentHint=localization.GetByLabel( 'UI/PI/Common/PayloadIsEmpty'), headers=[ '', localization.GetByLabel('UI/PI/Common/Type'), localization.GetByLabel('UI/Common/Quantity') ]) self.costText.text = localization.GetByLabel( 'UI/PI/Common/LaunchCost', iskAmount=util.FmtISK( self.pin.GetExportTax(self.payloadCommodities)))
def __AddToList(self, war, scrolllist): data = util.KeyVal() data.label = '' data.war = war if self.myWars: data.myWars = True else: data.myWars = False scrolllist.append(listentry.Get('WarEntry', data=data))
def LoadScrollList(self): scrolllist = [] subSystemsByGroupID = self.GetSubSystemsByGroup() subSystemGroups = [] for subSystemGroupID in subSystemsByGroupID: if self.groupIDs is not None and subSystemGroupID in self.groupIDs: continue subSystemGroup = cfg.invgroups.Get(subSystemGroupID) subSystemGroups.append((subSystemGroup.groupName, subSystemGroup)) subSystemGroups = uiutil.SortListOfTuples(subSystemGroups) godma = sm.GetService('godma') for groupRow in cfg.groupsByCategories.get(const.categorySubSystem, []): groupID = groupRow.groupID if self.groupIDs is not None and groupID in self.groupIDs: continue group = cfg.invgroups.Get(groupID) scrolllist.append( listentry.Get('Header', {'label': group.groupName})) types = [] typeIDs = [] if group.groupID in subSystemsByGroupID: for subSystemTypeID, subSystemItemID in subSystemsByGroupID[ group.groupID]: if subSystemTypeID not in typeIDs: subSystemType = cfg.invtypes.Get(subSystemTypeID) types.append((subSystemType.typeName, subSystemType, subSystemItemID)) typeIDs.append(subSystemTypeID) types.sort() first = True for typeName, type, itemID in types: data = util.KeyVal() data.label = type.typeName data.typeID = type.typeID data.showinfo = 1 data.itemID = itemID data.OnClick = self.ClickEntry if groupID in self.startSubSystems and type.typeID == self.startSubSystems[ groupID] or not self.startSubSystems and first: data.isSelected = 1 else: data.isSelected = 0 if data.isSelected: slotFlag = int( godma.GetTypeAttribute(type.typeID, const.attributeSubSystemSlot)) self.subSystems[slotFlag] = itemID self.selectedSubSystemsByFlag[slotFlag] = itemID first = False scrolllist.append(listentry.Get('AssembleShipEntry', data=data)) self.UpdateHint() self.scroll.Load(contentList=scrolllist, scrolltotop=0)
def GetPlanetInfo(self, planetID, hierarchy=False): solarSystemID, typeID = self.GetMapCache()['planets'][planetID] info = util.KeyVal(solarSystemID=solarSystemID, typeID=typeID) if hierarchy: regionID, constellationID, x = self.GetItem(solarSystemID, retall=True).hierarchy info.regionID = regionID info.constellationID = constellationID return info
def ApplyAttributes(self, attributes): uicontrols.Window.ApplyAttributes(self, attributes) fileList = attributes.fileList self.selected = fileList[0][0] + '.pos' self.SetCaption('Assemble Starbase') self.MakeUnResizeable() self.SetMinSize([256, 256], 1) self.SetWndIcon(None) self.SetTopparentHeight(0) guts = uiprimitives.Container( parent=self.sr.main, pos=(const.defaultPadding, const.defaultPadding, const.defaultPadding, const.defaultPadding), align=uiconst.TOALL) uicontrols.Combo(label='Select POS file', parent=guts, options=fileList, name='fileselect', select=0, align=uiconst.TOTOP, pos=(0, 20, 0, 0), width=200, callback=self.OnComboChange) scroll = uicontrols.Scroll(parent=guts, padding=(0, const.defaultPadding, 0, const.defaultPadding)) scrolllist = [] for cfgname, var, label, group in [ ['posTowerAnchor', 'TowerAnchor', 'Anchor Control Tower', None], [ 'posTowerFuel', 'TowerFuel', 'Fuel Control Tower (for onlining)', None ], ['posTowerOnline', 'TowerOnline', 'Online Control Tower', None], ['posStructAnchor', 'StructAnchor', 'Anchor All Structures', None], [ 'posStructFuel', 'StructFuel', 'Fuel Control Tower (for structures)', None ], ['posStructOnline', 'StructOnline', 'Online All Structures', None], ['posArmWeapons', 'ArmWeapons', 'Arm Weapon Batteries', None] ]: data = util.KeyVal() data.label = label data.checked = True data.cfgname = cfgname data.retval = var data.group = group data.OnChange = self.CheckBoxChange le = listentry.Get('Checkbox', data=data) scrolllist.append(le) setattr(self, var, True) setattr(self, var + 'LE', le) scroll.Load(contentList=scrolllist) buttons = [['Execute', self.Execute, None, 81], ['Cancel', self.Cancel, None, 81]] self.sr.main.children.insert(0, uicontrols.ButtonGroup(btns=buttons))
def GetNoItemEntry(self, sublevel, droneState, *args): data = util.KeyVal() data.droneState = droneState data.label = localization.GetByLabel('/Carbon/UI/Controls/Common/NoItem') data.sublevel = sublevel data.itemID = None data.OnDropData = lambda dragObject, nodes: self.DropDronesOnDroneEntry(data, dragObject, nodes) noItemEntry = listentry.Get('Generic', data=data) return noItemEntry
def GetDroppedCharInfo(node): if not IsUserNode(node): return charID = GetCharIDFromTextLink(node) if charID is None: charID = node.charID if util.IsCharacter(charID): charName = cfg.eveowners.Get(charID).name return util.KeyVal(charName=charName, charID=charID)
def _MakeDestroyedEntryData(self, item, indented = False): data = util.KeyVal() data.typeID = item.typeID data.qtyDestroyed = item.qtyDestroyed data.qtyDropped = None data.singleton = item.singleton data.flag = item.flag data.indented = indented return data
def RegisterCameraStartupInfo(self, yaw, pitch, zoom): """ Saves a specific yaw, pitch and zoom so that it can be used in derived services for initializing the camera correctly (e.g. on avatar creation) """ self.cameraStartupInfo = util.KeyVal(yaw=yaw, pitch=pitch, zoom=zoom) cam = self.GetActiveCamera() cam.yaw = yaw cam.pitch = pitch
def GetShipExposureTemplateData(self): if not eve.stationItem: return racialShips = {const.raceAmarr: [2006, 20183, 24696, 24692, 597, 1944, 624], const.raceCaldari: [621, 20185, 24698, 640, 602, 648, 623], const.raceGallente: [627, 20187, 24700, 641, 593, 650, 626], const.raceMinmatar: [629, 20189, 24702, 644, 587, 653, 622]} oreShipsList = [17478, 17476, 2998] racialIntroVideos = {const.raceAmarr: 'res:/video/cq/LOGO_AMARR.bik', const.raceCaldari: 'res:/video/cq/LOGO_CALDARI.bik', const.raceGallente: 'res:/video/cq/LOGO_GALLENTE.bik', const.raceMinmatar: 'res:/video/cq/LOGO_MINMATAR.bik'} data = util.KeyVal() if random.random() <= 0.3: data.introVideoPath = 'res:/video/cq/LOGO_ORE.bik' data.shipTypeID = random.choice(oreShipsList) else: stationType = cfg.invtypes.Get(eve.stationItem.stationTypeID) stationRace = stationType['raceID'] if stationRace not in racialShips: stationRace = const.raceGallente data.introVideoPath = racialIntroVideos[stationRace] data.shipTypeID = random.choice(racialShips[stationRace]) shipCachedInfo = cfg.invtypes.Get(data.shipTypeID) data.shipName = shipCachedInfo.name data.shipGroupName = shipCachedInfo.Group().groupName data.buttonText = localization.GetByLabel('UI/Station/Holoscreen/Common/AvailableOnMarketNow') data.mainText = '<fontsize=30>' + localization.GetByLabel('UI/Station/Holoscreen/Ship/ShipDetailsTitle') data.mainText += '\n<fontsize=25>' + shipCachedInfo.description data.clickFunc = sm.GetService('marketutils').ShowMarketDetails data.clickArgs = (data.shipTypeID, None) data.clickFuncLabel = localization.GetByLabel('UI/Station/Holoscreen/Ship/OpenMarketForShip', ship=data.shipTypeID) return data
def AddStuff(self, key, item, toDict): if key not in toDict: toDict[key] = util.KeyVal(itemID=item.itemID, typeID=item.typeID, quantity=item.quantity, name=item.name, item=item.item) else: toDict[key].quantity += item.quantity
def GetSkillTrainingTemplateData(self): if sm.GetService('skills').SkillInTraining() is not None: return data = util.KeyVal() data.introVideoPath = 'res:/video/cq/LOGO_CONCORD.bik' data.headingText = localization.GetByLabel('UI/Station/Holoscreen/SkillTraining/Title') data.subHeadingText = localization.GetByLabel('UI/Station/Holoscreen/SkillTraining/Notification') data.clickFunc = uicore.cmd.OpenSkillQueueWindow data.clickFuncLabel = localization.GetByLabel('UI/Station/Holoscreen/SkillTraining/OpenSkillQueue') return data
def GetNPEEpicArcTemplateData(self): rookieList = self.holoscreenMgr.GetRecentEpicArcCompletions() if not rookieList: rookieData = util.KeyVal(characterID=session.charid, completionDate=blue.os.GetWallclockTime()) else: rookieData = random.choice(rookieList) data = util.KeyVal(charID=rookieData.characterID) charInfo = cfg.eveowners.Get(data.charID) completionDate = util.FmtDate(rookieData.completionDate) data.introVideoPath = 'res:/video/cq/LOGO_CONCORD.bik' data.heading = localization.GetByLabel('UI/Station/Holoscreen/NPEEpicArc/NewPilotCertification') data.mainText = '<fontsize=25>' + localization.GetByLabel('UI/Station/Holoscreen/NPEEpicArc/CapsuleerStatus', owner=data.charID, completionDate=completionDate) data.mainText += '<br><fontsize=20>' + localization.GetByLabel('UI/Station/Holoscreen/NPEEpicArc/CertificationDisclaimer') data.bottomText = localization.GetByLabel('UI/Station/Holoscreen/NPEEpicArc/NewPilotCertificationCompletion', pilot=data.charID) data.isWanted = False data.clickFunc = sm.GetService('info').ShowInfo data.clickArgs = (charInfo.Type().typeID, data.charID) data.clickFuncLabel = localization.GetByLabel('UI/Station/Holoscreen/NPEEpicArc/ViewCharacterInformation') return data
def GetInfrastructureHubItemData(self, hubID): inv = sm.GetService('invCache').GetInventoryFromId(hubID) itemData = {} for item in inv.List(): itemData[item.typeID] = util.KeyVal(itemID=item.itemID, typeID=item.typeID, groupID=item.groupID, flagID=item.flagID) return itemData
def _GetTeam(self, teamID): """ Returns a team by ID or None if not found. """ try: team = sm.GetService('industryTeamSvc').GetTeam(teamID) return industryCommon.JobTeam( util.KeyVal(team=team, isInAuction=False)) except KeyError: return None
def AddToHistory(self, url, title, timestamp): while len(self.history) > MAX_HISTORY_LENGTH: self.history.pop() h = util.KeyVal() h.url = url h.title = title h.ts = timestamp self.history.appendleft(h) self.historyIsDirty = True