def StartWatching(self, isit): self.SaveConfig() self.isRunning = isit if self.isRunning: txt = 'ISK Spaminator tool started @ %s' % util.FmtDate( blue.os.GetTime()) self.LogNotice(txt) self.startedTime = util.FmtDate(blue.os.GetTime(), 'ls') self.stats = { 'numMessages': 0, 'numNotify': 0, 'numDetention': 0, 'numServerCalls': 0 } self.wnd.SetCaption(CAPTION + ' (RUNNING)') elif self.startedTime: txt = 'ISK Spammer tool stopped @ %s' % util.FmtDate( blue.os.GetTime()) self.LogNotice(txt) statsFileName = self.path + 'stats.txt' o = file(statsFileName, 'a') o.write('ISK Spammer tool running from %s to %s\n%s\n' % (self.startedTime, util.FmtDate(blue.os.GetTime(), 'ls'), '=' * 60)) for k, v in self.stats.iteritems(): o.write('%s:\t%s\n' % (k, v)) o.write('\n\n') o.close() self.startedTime = None self.wnd.SetCaption(CAPTION + ' (stopped)') else: return eve.Message('CustomNotify', {'notify': txt})
def OnTabOffices(self): scrolllist = [] scrollHeaders = [localization.GetByLabel('UI/Corporations/Common/Offices'), localization.GetByLabel('UI/Station/OfficeNumber'), localization.GetByLabel('UI/Station/StationManagment/OfficeRentedBy'), localization.GetByLabel('UI/Station/StationManagment/RentStartDate'), localization.GetByLabel('UI/Station/StationManagment/RentPeriod'), localization.GetByLabel('UI/Station/StationManagment/RentPeriodCost'), localization.GetByLabel('UI/Station/StationManagment/RentBalanceDue')] for each in self.rentableItems: if each.typeID == const.typeOfficeFolder: pass else: log.LogError('Unknown typeID on Corporation Folder %s (typeID) %s (CorpID)' % each.typeID, eve.session.corpid) continue rname = '' if each.rentedToID is not None: rname = localization.GetByLabel('UI/Station/StationManagment/OfficesTableRentedBy', rentername=cfg.eveowners.Get(each.rentedToID).name) dataLabel = '<t>'.join([localization.GetByLabel('UI/Station/StationManagment/OfficesTablePubliclyAvailable'), util.FmtAmt(each.number), rname, util.FmtDate(each.startDate, 'ln') if each.startDate else u'', util.FmtAmt(each.rentPeriodInDays) if each.rentPeriodInDays else u'', util.FmtISK(each.periodCost) if each.periodCost else u'', util.FmtDate(each.balanceDueDate, 'ln') if each.balanceDueDate else u'']) data = {'label': dataLabel, 'checked': each.publiclyAvailable, 'cfgname': 'offices', 'retval': 'type%s_number%s' % (each.typeID, each.number), 'OnChange': self.CheckBoxChange, 'name': 'offices_type%s_number%s' % (each.typeID, each.number)} scrolllist.append(listentry.Get('Checkbox', data)) self.ddxFunction = self.DDXTabOffices self.sr.scroll2.Load(fixedEntryHeight=24, contentList=scrolllist, headers=scrollHeaders)
def __init__(self): self.servicebroker = None self.client = 0 self.server = 0 self.totalLogonSteps = 10 self.bulkIDsToCfgNames = {} self.bulkEntries = [] import __builtin__ __builtin__.const = const self.fmtMapping = {} self.fmtMapping[ const.UE_DATETIME] = lambda value, value2: util.FmtDate(value) self.fmtMapping[ const.UE_DATE] = lambda value, value2: util.FmtDate(value, 'ln') self.fmtMapping[ const.UE_TIME] = lambda value, value2: util.FmtDate(value, 'nl') self.fmtMapping[ const.UE_TIMESHRT] = lambda value, value2: util.FmtDate( value, 'ns') self.fmtMapping[ const.UE_MSGARGS] = lambda value, value2: cfg.GetMessage( value[0], value[1]).text self.fmtMapping[ const.UE_LOC] = lambda value, value2: self._GetLocalization( value, value2) self.fmtMapping[ const. UE_MESSAGEID] = lambda value, value2: self._GetLocalizationByID( value, value2) self.fmtMapping[const.UE_LIST] = lambda value, value2: self._GetList( value, value2)
def SetEndPointDates(self): uix.Flush(self.sr.dates) uicls.EveLabelMedium(text=util.FmtDate(blue.os.GetWallclockTime()), parent=self.sr.dates, align=uiconst.TORIGHT) uicls.EveLabelMedium(text=util.FmtDate(blue.os.GetWallclockTime()), parent=self.sr.dates, align=uiconst.TOLEFT)
def GetKills(self, scroll, shipGroup=None): sortedScrolllist = [] myDate = None killValue = self.killsFilterCombo.GetValue() kills = self.warStatisticMoniker.GetKills(killValue, shipGroup) validGroupIDs = None if shipGroup is not None: validGroupIDs = cfg.GetShipGroupByClassType()[shipGroup] for kill in kills: if self.attackerID in (kill.finalCorporationID, kill.finalAllianceID): attackerKill = True else: attackerKill = False if killValue == 'attacker' and attackerKill == False: continue elif killValue == 'defender' and attackerKill == True: continue data = util.KeyVal() data.label = '' data.killID = kill.killID data.killTime = kill.killTime data.finalCharacterID = kill.finalCharacterID data.finalCorporationID = kill.finalCorporationID data.finalAllianceID = kill.finalAllianceID data.victimCharacterID = kill.victimCharacterID data.victimCorporationID = kill.victimCorporationID data.victimAllianceID = kill.victimAllianceID data.victimShipTypeID = kill.victimShipTypeID data.attackerKill = attackerKill data.mail = kill sortedScrolllist.append( (kill.killTime, listentry.Get('WarKillEntry', data=data))) sortedScrolllist = uiutil.SortListOfTuples(sortedScrolllist, reverse=True) scrolllist = [] for entry in sortedScrolllist: if myDate is None or myDate != util.FmtDate(entry.killTime, 'sn'): scrolllist.append( listentry.Get( 'Header', {'label': util.FmtDate(entry.killTime, 'sn')})) myDate = util.FmtDate(entry.killTime, 'sn') scrolllist.append(entry) scroll.Load(contentList=scrolllist, headers=[], noContentHint=localization.GetByLabel( 'UI/Corporations/Wars/NoKillsFound'))
def _export_history_by_type(type_id, deep=31): history = sm.GetService('marketQuote').GetPriceHistory(type_id) if abs(deep) > len(history) - 1: deep = 0 elif deep > 0: deep *= -1 history = history[deep:-1] history = [list(x) for x in history] for h in history: h[0] = util.FmtDate(h[0]) h.insert(0, eve.session.regionid) h.insert(1, type_id) # Очищаем историю для текущего региона и товара query = "DELETE FROM trade_histories WHERE region_id = %s AND type_id = %s" sm.bot.db.query(query, (eve.session.regionid, type_id)) history = [tuple(x) for x in history] # Сохраняем историю для текущего региона и товра query = "INSERT INTO trade_histories " \ "(region_id, type_id, history_date, low_price, high_price, avg_price, volume, orders) " \ "VALUES(%s, %s, %s, %s, %s, %s, %s, %s)" sm.bot.db.query(query, history)
def ReportISKSpammer(charID, channelID): if eve.Message('ConfirmReportISKSpammer', {'name': cfg.eveowners.Get(charID).name}, uiconst.YESNO) != uiconst.ID_YES: return if charID == session.charid: raise UserError('ReportISKSpammerCannotReportYourself') lscSvc = sm.GetService('LSC') c = lscSvc.GetChannelWindow(channelID) entries = copy.copy(c.output.GetNodes()) spamEntries = [] for e in entries: if e.charid == charID: who, txt, charid, time, colorkey = e.msg spamEntries.append('[%s] %s > %s' % (util.FmtDate(time, 'nl'), who, txt)) if len(spamEntries) == 0: raise UserError('ReportISKSpammerNoEntries') spamEntries.reverse() spamEntries = spamEntries[:10] spammers = getattr(lscSvc, 'spammerList', set()) if charID in spammers: return spammers.add(charID) lscSvc.spammerList = spammers c.LoadMessages() channel = lscSvc.channels.get(channelID, None) if channel and channel.info: channelID = channel.info.displayName sm.RemoteSvc('userSvc').ReportISKSpammer(charID, channelID, spamEntries)
def GetJournalSubContent(self, nodedata, *args): items = sm.GetService('account').GetJournal(nodedata.keyID, nodedata.fromDate, None, 1) scrolllist = [] for row in items: if row.entryTypeID == const.refSkipLog: continue data = {} if row.entryTypeID in (const.refMarketEscrow, const.refTransactionTax, const.refBrokerfee): actor = cfg.eveowners.Get(row.ownerID1).name else: actor = '' data['label'] = '%s<t>%s<t>%s<t>%s<t>%s' % ( util.FmtDate(row.transactionDate, 'ls'), row.transactionID, util.FmtCurrency( row.amount, currency=None, showFractionsAlways=0), util.FmtRef(row.entryTypeID, row.ownerID1, row.ownerID2, row.referenceID, amount=row.amount), actor) data['sort_%s' % localization.GetByLabel( 'UI/Common/Date')] = row.transactionDate data['sort_%s' % localization.GetByLabel('UI/Common/Amount')] = row.amount data['sort_%s' % localization.GetByLabel('UI/Common/ID')] = row.transactionID scrolllist.append(listentry.Get('Generic', data)) return scrolllist
def ShowJournal(self, *args): if self is not None and not self.destroyed: sm.GetService('corpui').ShowLoad() else: return if (const.corpRoleAccountant | const.corpRoleJuniorAccountant) & eve.session.corprole == 0: self.SetHint(localization.GetByLabel('UI/Corporations/Assets/NeedAccountantRole')) self.sr.scroll.Clear() sm.GetService('corpui').HideLoad() return keymap = sm.GetService('account').GetKeyMap() scrolllist = [] for row in keymap: label = '%s (%s - %s)' % (row.keyName.capitalize(), util.FmtDate(self.sr.journalFromDate, 'ls'), util.FmtDate(self.sr.journalToDate, 'ls')) data = {'GetSubContent': self.GetJournalSubContent, 'label': label, 'groupItems': None, 'id': ('corpaccounts', row.keyName), 'tabs': [], 'state': 'locked', 'accountKey': row.keyID, 'showicon': 'hide', 'fromDate': self.sr.journalFromDate} scrolllist.append(listentry.Get('Group', data)) self.sr.scroll.Load(fixedEntryHeight=19, contentList=scrolllist, headers=[localization.GetByLabel('UI/Common/Date'), localization.GetByLabel('UI/Common/ID'), localization.GetByLabel('UI/Common/Amount'), localization.GetByLabel('UI/Common/Description'), localization.GetByLabel('UI/Common/Amount')]) sm.GetService('corpui').HideLoad()
def UpdateProgram(self, replaceHeadID=None, point=None): if self.currentResource is None: return heads = self.pin.heads[:] if self.editsEnabled: if replaceHeadID is not None: for each in self.pin.heads: if each[0] == replaceHeadID: heads.remove(each) heads.append((replaceHeadID, point.phi, point.theta)) break colony = self.GetColony() maxValue, cycleTime, numCycles, self.overlapValues = colony.CreateProgram( self.currentResource, self.pin.id, self.currResourceTypeID, points=heads, headRadius=self.currentRadius) self.UpdateOverlapValues() self.planetUISvc.myPinManager.SetEcuOverlapValues( self.pin.id, self.overlapValues) else: maxValue, cycleTime, numCycles = self.pin.GetProgramParameters() self.currCycleTime = cycleTime xLabels = (localization.GetByLabel('UI/PI/Common/SurveyProgramStart'), util.FmtDate(cycleTime * numCycles)) self.UpdateBarGraph(maxValue, cycleTime, numCycles, xLabels)
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 Load(self, node): self.sr.node = node freeRespecs = node.Get('freeRespecs', 0) nextRespecTime = node.Get('nextTimedRespec', None) canRemap = False if nextRespecTime is None or nextRespecTime <= blue.os.GetWallclockTime( ): self.sr.respecTime.text = localization.GetByLabel('UI/Generic/Now') canRemap = True else: self.sr.respecTime.text = util.FmtDate(node.nextTimedRespec) self.refreshThread = uthread.new(self.RefreshThread) if freeRespecs > 0: canRemap = True lbl = localization.GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/Attributes/BonusRemapsAvailable', remapsAvailable=freeRespecs) self.sr.numberOfRemaps.text = lbl if nextRespecTime is not None and nextRespecTime > blue.os.GetWallclockTime( ): self.hint = localization.GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/Attributes/CharacterSheetHintFree' ) else: self.hint = localization.GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/Attributes/CharacterSheetHintFreeTimed' ) self.sr.numberOfRemaps.state = uiconst.UI_DISABLED if not canRemap: self.sr.respecButton.SetLabel( localization.GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/Attributes/AttributesOverview' )) self.sr.respecButton.args = (True, )
def OnClusterShutdownInitiated(self, explanationLabel, when, duration): now = blue.os.GetWallclockTime() subtitle = localization.GetByLabel( 'UI/Shared/ShutdownNotificationSubtitleNoDelay') message = localization.GetByLabel( explanationLabel, intervalRemaining=localization.formatters. FormatTimeIntervalWritten( when - now, showTo=localization.formatters.TIME_CATEGORY_MINUTE), shutdownTime=util.FmtDate(when, 'ns')) if duration: subtitle = localization.GetByLabel( 'UI/Shared/ShutdownNotificationSubtitleWithDelay', delay=localization.formatters.FormatTimeIntervalWritten( when - now, showTo=localization.formatters.TIME_CATEGORY_MINUTE)) message += localization.GetByLabel( '/EVE-Universe/ClusterBroadcast/DowntimeMessageSuffix', downtimeInterval=localization.formatters. FormatTimeIntervalWritten( duration * const.MIN, showTo=localization.formatters.TIME_CATEGORY_MINUTE)) notification = Notification( notificationID=1, typeID=notificationConst.notificationTypeServerShutdown, senderID=None, receiverID=session.charid, processed=0, created=blue.os.GetWallclockTime(), data={'text': message}) notification.subject = localization.GetByLabel( 'UI/Shared/ShutdownNotificationTitle') notification.subtext = subtitle sm.ScatterEvent('OnNewNotificationReceived', notification)
def Load(self, node): ContractEntrySearch.Load(self, node) c = node.contract self.sr.contractLabel.text = '<color=0xFFFFA600>%s</color>' % self.GetLocationText( c.startSolarSystemID, c.startRegionID, c.startStationID) self.sr.toLabel.text = '<color=0xFFFFA600>%s</color>' % self.GetLocationText( c.endSolarSystemID, None, c.endStationID) routeLength = node.routeLength self.sr.volumeLabel.text = '%s m\xb3' % util.FmtAmt( c.volume, showFraction=0 if c.volume > 10 else 2) self.sr.rewardLabel.text = '<color=white>%s</color>' % [ localization.GetByLabel('UI/Contracts/ContractEntry/NoneParen'), FmtISKWithDescription(c.reward, True) ][c.reward > 0] self.sr.collateralLabel.text = '<color=white>%s</color>' % [ localization.GetByLabel('UI/Contracts/ContractEntry/NoneParen'), FmtISKWithDescription(c.collateral, True) ][c.collateral > 0] if int(routeLength) > cc.NUMJUMPS_UNREACHABLE: numJumpsTxt = '<color=0xffff6666>%s</color>' % localization.GetByLabel( 'UI/Generic/Unreachable').upper() elif routeLength == 0: numJumpsTxt = localization.GetByLabel( 'UI/Contracts/ContractEntry/SameSystem') elif routeLength == 1: numJumpsTxt = localization.GetByLabel( 'UI/Contracts/ContractEntry/NextSystem') else: numJumpsTxt = localization.GetByLabel( 'UI/Contracts/ContractEntry/NumJumps', numJumps=routeLength) self.sr.routeLabel.text = '<color=white>%s</color>' % numJumpsTxt self.sr.issuerLabel.text = node.issuer self.sr.createdLabel.text = '%s' % util.FmtDate(node.dateIssued, 'ss') self.sr.infoLabel.text = c.title
def Load(self, node): ContractEntrySearch.Load(self, node) c = node.contract p = c.price self.sr.locationLabel.text = self.GetLocationText( c.startSolarSystemID, c.startRegionID, c.startStationID) if p == 0 and c.reward > 0: txt = '<color=0xff999999>-%s</color>' % FmtISKWithDescription( c.reward, True) else: txt = '<color=white>%s</color>' % FmtISKWithDescription(p, True) self.sr.priceLabel.SetText(txt) if localization.GetByLabel('UI/Contracts/ContractEntry/WantToBuy' ) not in self.sr.contractLabel.text: if len([e for e in node.contractItems if not e.inCrate]) >= 1: self.sr.priceLabel.text += '<br>[%s]' % localization.GetByLabel( 'UI/Generic/Items') if c.type == const.conTypeAuction: self.sr.priceLabel.text = '<color=white>%s</color>' % FmtISKWithDescription( GetCurrentBid(c, node.bids), True) if c.collateral: self.sr.priceLabel.text += '<br>(%s)' % FmtISKWithDescription( c.collateral, True) else: self.sr.priceLabel.text += '<br>(%s)' % localization.GetByLabel( 'UI/Contracts/ContractEntry/NoBuyoutPrice') self.sr.issuerLabel.text = node.issuer self.sr.createdLabel.text = '%s' % util.FmtDate(node.dateIssued, 'ss') self.sr.infoLabel.text = c.title
def GetMethodCalls(self): txt = 'Time\tMethod\tDuration [ms]\n' entries = base.methodCallHistory for e in entries: txt += '%s\t%s\t%s\n' % (util.FmtDate( e[1], 'sl'), e[0], e[2] / const.MSEC) return txt
def OnAreaSliderMoved(self, slider): AreaSlider.OnSetValue(slider, slider) cycleTime, numCycles = self._GetCycleTimeAndNumCyclesFromSliderVal( slider.value) cycleTime = int(cycleTime * const.HOUR) self.barGraph.SetXLabels( (localization.GetByLabel('UI/PI/Common/SurveyProgramStart'), util.FmtDate(cycleTime * numCycles)))
def CreateScrolllist(self, ownerID): scrolllist = [] for itemID in self.stuff: item = self.stuff[itemID] if item.ownerID != ownerID: continue itemName = '' if item.categoryID == const.categoryShip: shipName = cfg.evelocations.GetIfExists(item.itemID) if shipName is not None: itemName = shipName.locationName contract = None if self.contracts.has_key(item.itemID): contract = self.contracts[item.itemID] name = evetypes.GetName(item.typeID) if contract is None: label = '%s<t>%s<t>%s<t>%s<t>%s' % (name, '-', '-', '-', itemName) else: label = '%s<t>%s<t>%s<t>%s<t>%s' % ( name, util.FmtDate(contract.startDate, 'ls'), util.FmtDate(contract.endDate, 'ls'), sm.GetService('insurance').GetInsuranceName( contract.fraction), itemName) if ownerID == session.charid: onDblClickFunc = self.OnEntryDblClick onClickFunc = self.OnEntryClick else: onDblClickFunc = self.OnCorpEntryDblClick onClickFunc = self.OnCorpEntryClick data = { 'info': item, 'itemID': item.itemID, 'typeID': item.typeID, 'label': label, 'getIcon': 1, 'GetMenu': self.GetItemMenu, 'OnDblClick': onDblClickFunc, 'selected': True, 'OnClick': onClickFunc } entry = listentry.Get('Item', data) scrolllist.append(entry) return scrolllist
def PopulateScroll(self, *args): 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(ScrollEntryNode(decoClass=SE_GenericCore, label=label)) self.scroll.Load(contentList=scrolllist, headers=['method', 'time', 'dt'])
def Load(self, node): ContractEntrySearch.Load(self, node) c = node.contract p = c.price self.sr.locationLabel.text = self.GetLocationText(c.startSolarSystemID, c.startRegionID) self.sr.currentBidLabel.text = '<color=white>%s</color>' % FmtISKWithDescription(GetCurrentBid(c, node.bids), True) self.sr.buyoutLabel.text = '%s' % ['<color=0xff999999>' + localization.GetByLabel('UI/Contracts/ContractEntry/NoneParen') + '</color>', '<color=white>' + FmtISKWithDescription(c.collateral, True) + '</color>'][c.collateral > 0] self.sr.bidsLabel.text = '%s' % node.searchresult.numBids self.sr.issuerLabel.text = node.issuer self.sr.createdLabel.text = '%s' % util.FmtDate(node.dateIssued, 'ss')
def GetWarDateText(self): war = self.war date = util.FmtDate(war.timeDeclared, 'sn') if war.timeDeclared else localization.GetByLabel('UI/Common/Unknown') warFinished = util.FmtDate(war.timeFinished, 'sn') if war.timeFinished else None warRetracted = util.FmtDate(war.retracted, 'sn') if war.retracted is not None else None warMutual = war.mutual if blue.os.GetWallclockTime() <= war.timeStarted: fightTime = util.FmtDate(war.timeStarted, 'ns') timeText = localization.GetByLabel('UI/Corporations/Wars/WarStartedCanFightDetailed', date=date, time=fightTime) elif warFinished: if blue.os.GetWallclockTime() < war.timeFinished: endTime = util.FmtDate(war.timeFinished, 'ns') timeText = localization.GetByLabel('UI/Corporations/Wars/WarStartedEndsAt', date=date, time=endTime) else: timeText = localization.GetByLabel('UI/Corporations/Wars/WarStartedAndFinished', startDate=date, finishDate=warFinished) elif warRetracted: timeText = localization.GetByLabel('UI/Corporations/Wars/WarStartedWarRetracted', date=date, endDate=warRetracted) else: timeText = localization.GetByLabel('UI/Corporations/Wars/WarStarted', date=date) return timeText
def CalculateUpgradeCost(self, solarsystemID, typeIDs): claimTime = self.GetSystemSovereigntyInfo(solarsystemID, forceUpdate=True).claimTime daysHeld = (blue.os.GetWallclockTimeNow() - claimTime) / const.DAY daysLeft = const.sovereignityBillingPeriod - daysHeld % const.sovereignityBillingPeriod self.LogInfo('claimTime is', claimTime, util.FmtDate(claimTime), 'which amounts to ', daysHeld, 'days. days left for this billing cycle are', daysLeft) total = 0 omygodma = sm.StartService('godma') for tID in typeIDs: total = omygodma.GetTypeAttribute(tID, const.attributeSovBillSystemCost, 0) return (daysLeft, total)
def CountDown(self, startTime, duration): while True and not self.destroyed: dt = blue.os.TimeDiffInMs(startTime, blue.os.GetWallclockTimeNow()) if dt > duration: break self.progressText.text = util.FmtDate( long((duration - dt) * 10000) + const.SEC) blue.pyos.synchro.SleepWallclock(10) if not self.destroyed: self.progressText.text = util.FmtDate(0L) self.Abort()
def RenderTable(self): scroll = uicontrols.Scroll(parent=self, padding=(1, 1, 1, 1)) scroll.sr.id = 'pricehistoryscroll' scroll.smartSort = 0 scroll.OnColumnChanged = self.OnColumnChanged history = sm.GetService('marketQuote').GetPriceHistory( self.typerecord.typeID) windowData = settings.user.ui.Get('pricehistorytime', 90) if len(history) > windowData: history = history[-(windowData + 1):] scrolllist = [] for rec in history: text = '%s<t>%s<t>%s<t>%s<t>%s<t>%s' % ( util.FmtDate(rec[0]), util.FmtAmt(rec[5]), util.FmtAmt( rec[4]), util.FmtCurrency(rec[1], currency=None), util.FmtCurrency(rec[2], currency=None), util.FmtCurrency(rec[3], currency=None)) data = util.KeyVal() data.label = text data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/Quantity'), rec[4]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory'), rec[5]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/LowestPrice'), rec[1]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/HighestPrice'), rec[2]) data.Set( 'sort_%s' % localization.GetByLabel('UI/Market/PriceHistory/AveragePrice'), rec[3]) data.Set('sort_%s' % localization.GetByLabel('UI/Common/Date'), rec[0]) scrolllist.append(listentry.Get('Generic', data=data)) headers = [ localization.GetByLabel('UI/Common/Date'), localization.GetByLabel('UI/Market/PriceHistory'), localization.GetByLabel('UI/Market/PriceHistory/Quantity'), localization.GetByLabel('UI/Market/PriceHistory/LowestPrice'), localization.GetByLabel('UI/Market/PriceHistory/HighestPrice'), localization.GetByLabel('UI/Market/PriceHistory/AveragePrice') ] scroll.Load(fixedEntryHeight=18, contentList=scrolllist, headers=headers)
def CanInstallProgram(self, runTime): if self.programType is None: return True if runTime is not None: if self.expiryTime <= runTime: return True nextEditTime = self.installTime + PROGRAM_INSTALLATION_COOLDOWN if nextEditTime <= runTime: return True raise UserError('CantInstallProgramNeedsCooldown', {'ecu': (const.UE_TYPEID, self.typeID), 'timeDiff': util.FmtDate(nextEditTime - runTime)}) else: return True
def Start(self): now = blue.os.GetWallclockTime() datestr = util.FmtDate(now, 'sl') datestr = datestr.replace('.', '') datestr = datestr.replace(':', '') datestr = datestr.replace(' ', '') import os self.file = file(os.path.join(blue.paths.ResolvePath(u'cache:/'), 'prfl' + datestr + '.txt'), 'w') self.file.write('<profiling>\r\n') self.file.write('<data name="time" type="int">' + datestr[-6:] + '</data>\r\n') self.file.write('<data name="date" type="int">' + datestr[:-6] + '</data>\r\n') self.file.write('<data name="build" type="int">' + str(boot.build) + '</data>\r\n') self.startMem = blue.pyos.ProbeStuff()
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 GetInMemoryLogs(self): txt = 'Time\tFacility\tType\tMessage\r\n' entries = blue.logInMemory.GetEntries() entries.reverse() for e in entries: s = LOGTYPE_MAPPING.get(e[2], ('Unknown', '')) for line in e[4].split('\n'): try: txt += '%s\t%s::%s\t%s\t%s\r\n' % (util.FmtDate( e[3], 'nl'), e[0], e[1], s[0], line) except: txt += '***Error writing out logline***\r\n' return txt
def formatTowermail(self, n): data = n.data.copy() data["subject"] = strip_tags(str(n.subject)) data["body"] = strip_tags(str(n.body)) data["timestamp"] = util.FmtDate(n.created) data["moonName"] = getName(cfg.evelocations, n.data["moonID"]) data["typeName"] = getName(cfg.invtypes, n.data["typeID"]) data["aggressorName"] = getName(cfg.eveowners, n.data["aggressorID"]) data["aggressorCorpName"] = getName(cfg.eveowners, n.data["aggressorCorpID"]) data["aggressorAllianceName"] = getName(cfg.eveowners, n.data["aggressorAllianceID"]) data["shieldPercentage"] = int(float(n.data["shieldValue"]) * 100) return [l.format(**data) for l in TowermailFormat]
def DoUpdateLogs(self, loggingToWindow=True): wnd = self.GetWnd() scrolllist = [] entries = blue.logInMemory.GetEntries() logsToFile = [] if entries: 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( uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, label=label)) lineno += 1 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) MAXENTRIES = 5000 if len(wnd.sr.scroll.GetNodes()) > MAXENTRIES * 2: self.LogInfo('Reached', len(wnd.sr.scroll.GetNodes()), 'log entries. Truncating down to %d' % MAXENTRIES) wnd.sr.scroll.RemoveEntries(wnd.sr.scroll.GetNodes()[:-MAXENTRIES])