Пример #1
0
 def GetTopBounties(self, fetcher, page):
     newBounties, lastFetchingTime = fetcher(page)
     bountiesToCache = [
         bounty for bounty in newBounties
         if self.IsObsolete(bounty.targetID, lastFetchingTime)
     ]
     self.LogInfo('GetTopBounties::Got', len(newBounties), 'but caching',
                  len(bountiesToCache))
     bountyUtil.CacheBounties(self.bounties, bountiesToCache)
     return sorted(newBounties, key=lambda x: x.bounty, reverse=True)
Пример #2
0
 def SearchBounties(self, targetID):
     if util.IsCharacter(targetID):
         fetcher = sm.ProxySvc('bountyProxy').SearchCharBounties
     elif util.IsCorporation(targetID):
         fetcher = sm.ProxySvc('bountyProxy').SearchCorpBounties
     elif util.IsAlliance(targetID):
         fetcher = sm.ProxySvc('bountyProxy').SearchAllianceBounties
     bountyAndRank = fetcher(targetID)
     bountyUtil.CacheBounties(self.bounties,
                              [bounty for rank, bounty in bountyAndRank])
     return bountyAndRank
Пример #3
0
 def FetchBounties(self, targetIDs):
     bountiesToUpdate = {
         targetID
         for targetID in targetIDs if self.IsObsolete(targetID)
     }
     self.LogInfo('FetchBounties - Got', len(bountiesToUpdate),
                  'that are not cached or expired')
     if bountiesToUpdate:
         bounties = [
             bounty for targetID, bounty in self.GetBountiesFromServer(
                 bountiesToUpdate)
         ]
         bountyUtil.CacheBounties(self.bounties, bounties)
Пример #4
0
 def FetchBountiesAndKillRightsFromServer(self, charIDs, ownerIDs):
     bountiesToFetch = {
         ownerID
         for ownerID in ownerIDs if self.IsObsolete(ownerID)
     }
     killRightsToFetch = self.killRightTracker.GetInvalidKillRights(charIDs)
     self.LogInfo('FetchBountiesAndKillRightsFromServer - fetching',
                  len(bountiesToFetch), 'for bounties and',
                  len(killRightsToFetch), 'for killRights')
     if not (bountiesToFetch or killRightsToFetch):
         self.LogInfo(
             'FetchBountiesAndKillRightsFromServer - Bailing out because nothing to fetch'
         )
         return
     myKillRights, (bounties, killRights) = uthread.parallel([
         (self.GetMyKillRights, ()),
         (sm.ProxySvc('bountyProxy').GetBountiesAndKillRights,
          (bountiesToFetch, killRightsToFetch))
     ])
     bountyUtil.CacheBounties(self.bounties,
                              [bounty for targetID, bounty in bounties])
     self.killRightTracker.CacheKillRights(killRights, killRightsToFetch)
Пример #5
0
 def AddToBounty(self, ownerID, amount):
     newBounty = sm.ProxySvc('bountyProxy').AddToBounty(ownerID, amount)
     bountyUtil.CacheBounties(self.bounties, [newBounty])
     sm.GetService('objectCaching').InvalidateCachedMethodCall(
         'bountyProxy', 'GetMyBounties')