예제 #1
0
 def __init__(self, dogmaLocation, invItem, clientIDFunc, attributes=None):
     self._owner = None
     self.dogmaLocation = dogmaLocation
     self.dogmaLocation.dogmaItems[invItem.itemID] = self
     self.invItem = invItem
     self.itemID = invItem.itemID
     self.typeID = invItem.typeID
     self.groupID = invItem.groupID
     self.categoryID = invItem.categoryID
     self.reqSkills = dogmaLocation.dogmaStaticMgr.GetRequiredSkills(
         invItem.typeID)
     self.contentsChangedCallbacks = set()
     self.FindClientID = clientIDFunc
     attributeFactory = NewItemAttributeFactory(
         self, self.dogmaLocation, self.dogmaLocation.dogmaStaticMgr,
         attributes)
     self.attributes = keydefaultdict(attributeFactory.GetAttributeInstance)
     self.activeEffects = {}
     self._SetupLocationLinks()
     self._SetupLocationMods()
     self._SetupOwnerLinks()
     self._SetupOwnerMods()
     locationItem = self.location
     if locationItem:
         for callBack in locationItem.contentsChangedCallbacks:
             with ExceptionEater('Contents callback excepted'):
                 callBack(self)
예제 #2
0
 def Close(self):
     with ExceptionEater(
             'Could not unsubscribe from RedeemingQueueUpdated event'):
         account = sm.GetService('vgsService').GetStore().GetAccount()
         account.UnsubscribeFromRedeemingQueueUpdatedEvent(
             self.OnRedeemingQueueUpdated)
     uicontrols.ContainerAutoSize.Close(self)
예제 #3
0
 def LoadAd(self, inThread=False):
     if self.currentAdInfo == -1:
         self.showAd = False
         self.adSpriteContainer.state = uiconst.UI_HIDDEN
         return
     with ExceptionEater('Failed to load ad'):
         self.OpenAd(self.currentAdInfo, inThread=inThread)
예제 #4
0
 def LogInventoryMovement(self, item, locationID, oldOwnerID, qty,
                          sourceID):
     containerOwner = self.invItem.ownerID
     solarSystemID = self.invItem.locationID
     if locationID == locationJunkyard:
         with ExceptionEater('eventLog'):
             sm.GetService('eventLog').LogOwnerEvent(
                 'spacecomponent::cargobay_JunkingItem', containerOwner,
                 solarSystemID, self.component.itemID, sourceID, oldOwnerID,
                 item.itemID, item.typeID, qty)
             sm.GetService('eventLog').LogOwnerEventJson(
                 'spacecomponent::cargobay_JunkingItem',
                 containerOwner,
                 solarSystemID,
                 locationID=self.component.itemID,
                 sourceID=sourceID,
                 oldOwnerID=oldOwnerID,
                 itemID=item.itemID,
                 typeID=item.typeID,
                 quantity=qty)
     else:
         self.LogMoveItem(sourceID,
                          locationID,
                          oldOwnerID,
                          containerOwner,
                          self.invItem.groupID,
                          item=item,
                          qty=qty)
    def FindAvailableAds(self):
        adUrl = csUtil.GetCharacterSelectionAdPageUrl(session.languageID)
        feed = corebrowserutil.GetStringFromURL(adUrl).read()
        root = ET.fromstring(feed)
        namespaces = csUtil.xmlNamespaces
        itemlist = root.findall('atom:entry', namespaces=namespaces)
        targetedAds = []
        nonTargetedAds = []
        if session.userType == const.userTypeTrial:
            target = csUtil.adTrialTerm
        else:
            charData = self.GetCharacterSelectionData()
            creationDate = charData.GetUserCreationDate()
            now = blue.os.GetWallclockTime()
            if now - 6 * const.MONTH30 < creationDate:
                target = csUtil.adMediumTerm
            else:
                target = csUtil.adAdvancedTerm
        for eachItem in itemlist:
            with ExceptionEater('Failed to parse ad'):
                imageEntry = eachItem.find('ccpmedia:group/ccpmedia:content', namespaces=namespaces)
                linkEntry = eachItem.find('ccpmedia:group/ccpmedia:description', namespaces=namespaces)
                adID = eachItem.find('atom:id', namespaces=namespaces).text
                link = linkEntry.text
                imageUrl = imageEntry.attrib['url']
                imageWidth = imageEntry.attrib['width']
                imageHeight = imageEntry.attrib['height']
                adInfo = uiutil.Bunch(link=link, imageUrl=imageUrl, width=int(imageWidth), height=int(imageHeight), adID=adID)
                if eachItem.find("atom:category[@term='%s']" % target, namespaces=namespaces) is not None:
                    targetedAds.append(adInfo)
                elif eachItem.find('atom:category', namespaces=namespaces) is None:
                    nonTargetedAds.append(adInfo)

        return (targetedAds, nonTargetedAds)
예제 #6
0
    def Flush(self):
        for (solarSystemID, shipID), counter in self.counters.iteritems():
            with ExceptionEater('eventLog'):
                if solarSystemID and shipID and counter:
                    sm.ProxySvc('eventLog').LogClientEvent(
                        'flightControls', [
                            'solarSystemID', 'shipTypeID', 'counter', 'keyUp',
                            'keyDown', 'keyLeft', 'keyRight'
                        ], 'Counter', solarSystemID, self.ships.get(shipID),
                        counter, '+'.join([
                            uicore.cmd.GetKeyNameFromVK(key)
                            for key in self.controls.keyUp
                        ]), '+'.join([
                            uicore.cmd.GetKeyNameFromVK(key)
                            for key in self.controls.keyDown
                        ]), '+'.join([
                            uicore.cmd.GetKeyNameFromVK(key)
                            for key in self.controls.keyLeft
                        ]), '+'.join([
                            uicore.cmd.GetKeyNameFromVK(key)
                            for key in self.controls.keyRight
                        ]))

        self.counters.clear()
        self.ships.clear()
예제 #7
0
def GetCharacterCohorts(*args):
    with ExceptionEater(
            'Failed to query the gatekeeper. Returning [] for querying entity.'
    ):
        CohortFunction = GetCohortFunction(args)
        return _GetCohortsForCharacterFromService(CohortFunction)
    return []
예제 #8
0
 def OnSlimItemUpdated(self, slimItem):
     with ExceptionEater('ship::OnSlimItemUpdated failed'):
         self.typeData['slimItem'] = slimItem
         stanceID = self.GetStanceIDFromSlimItem(self.typeData['slimItem'])
         if stanceID != self.stanceID:
             self.lastStanceID = self.stanceID
             self.stanceID = stanceID
             spaceobjanimation.SetShipAnimationStance(self.model, stanceID)
예제 #9
0
 def DoBallsAdded(self, balls):
     with ExceptionEater('FlightControls.DoBallsAdded'):
         if any([
                 ball for ball, item in balls
                 if item.itemID == session.shipid
         ]):
             self.AttachShip()
             self.controls.Reset()
예제 #10
0
def CallPostponedFunctions():
    global postponedFunctionCalls
    if len(postponedFunctionCalls) > 0:
        logger.debug('Running postponed functions')
        for function, args, kwargs in postponedFunctionCalls:
            with ExceptionEater('Failed to run a postponed function'):
                function(*args, **kwargs)

        postponedFunctionCalls = []
예제 #11
0
 def SelectThemeFromShip(self):
     if settings.char.windows.Get('shiptheme', False):
         with ExceptionEater('SelectThemeFromShip'):
             typeID = sm.GetService('fleet').GetMyShipTypeID()
             if typeID:
                 themeID = colorThemes.FACTIONS.get(
                     cfg.fsdTypeOverrides.Get(typeID).factionID, None)
                 if themeID:
                     self.SetThemeID(themeID)
예제 #12
0
 def LogItemAndTypeOwnerEvent(self, eventName, item):
     with ExceptionEater('eventLog'):
         self.eventLog.LogOwnerEvent(eventName, item.ownerID,
                                     self.solarSystemID, item.itemID,
                                     item.typeID)
         self.eventLog.LogOwnerEventJson(eventName,
                                         item.ownerID,
                                         self.solarSystemID,
                                         componentItemID=item.itemID,
                                         componentTypeID=item.typeID)
예제 #13
0
 def LogExpiry(self, locationID, teamID):
     """
         Logs when an active team expires from the world.
     """
     with ExceptionEater('eventLog'):
         self.eventLog.LogOwnerEvent(EVENT_EXPIRY, const.ownerSystem,
                                     locationID, teamID)
         self.eventLog.LogOwnerEventJson(EVENT_EXPIRY,
                                         const.ownerSystem,
                                         locationID,
                                         teamID=teamID)
예제 #14
0
 def OnSlimItemUpdated(self, slimItem):
     with ExceptionEater('ship::OnSlimItemUpdated failed'):
         oldSlim = self.typeData['slimItem']
         self.typeData['slimItem'] = slimItem
         stanceID = self.GetStanceIDFromSlimItem(self.typeData['slimItem'])
         if stanceID != self.stanceID:
             self.lastStanceID = self.stanceID
             self.stanceID = stanceID
             spaceobjanimation.SetShipAnimationStance(self.model, stanceID)
         if getattr(oldSlim, 'skinMaterialSetID') != getattr(slimItem, 'skinMaterialSetID'):
             uthread.new(self.ChangeSkin)
예제 #15
0
 def IsInCohort(self, cohortID, *args):
     if self.IsInitialized():
         isInCohort = False
         with ExceptionEater(
                 'Failed to query the gatekeeper. Returning False for querying entity.'
         ):
             CohortFunction = self.GetCohortFunction(args)
             isInCohort = cohortID in self._GetCohortsForEntityFromService(
                 CohortFunction)
         return isInCohort
     raise RuntimeError('Gatekeeper not initialized')
예제 #16
0
 def OnAgentMissionChange(self, what, agentID, tutorialID=None, *args):
     with ExceptionEater(
             'exception during - missiontracker remove/add agent'):
         if what == 'quit':
             if agentID in self.agentList:
                 self.agentList.remove(agentID)
                 self.RemoveDestinationNotificationTrigger(agentID)
         if what == 'accepted':
             self.agentList.append(agentID)
             self.UpdateMissionStatusData((agentID, ))
     self.UpdateMissionsPanel()
예제 #17
0
def Teardown():
    """
        Teardown method used by unit tests to avoid repeated initializations.
    """
    global GetCohortFunction
    with ExceptionEater('Gatekeeper has not been initialized!'):
        if GetCohortFunction:
            GetCohortFunction = None
        else:
            raise RuntimeError('Gatekeeper has not been initialized!')
    CharacterIsInCohort.cache_clear()
    GetCharacterCohorts.cache_clear()
예제 #18
0
    def RegisterMissionTracking(self):
        with ExceptionEater('exception during RegisterMissionTracking'):
            missions = sm.GetService('journal').GetMyAgentJournalDetails()[0]
            for mission in missions:
                missionState, importantMission, missionType, missionNameID, agentID, expirationTime, bookmarks, remoteOfferable, remoteCompletable, contentID = mission
                if missionState != const.agentMissionStateAccepted or expirationTime and expirationTime < blue.os.GetWallclockTime(
                ):
                    continue
                else:
                    self.agentList.append(agentID)

            self.UpdateMissionStatusData(self.agentList)
예제 #19
0
    def _NameFetcher(self, nameQueue):
        while self.state == SERVICE_RUNNING:
            with ExceptionEater('voucherCache._NameFetcher'):
                requests = {}
                voucherID, responseChannel = nameQueue.receive()
                requests[voucherID] = responseChannel
                while nameQueue.balance:
                    voucherID, responseChannel = nameQueue.receive()
                    requests[voucherID] = responseChannel

                self.PrimeVoucherNames(requests.keys())
                for voucherID, responseChannel in requests.iteritems():
                    responseChannel.send(self.names[voucherID])
예제 #20
0
 def LogBid(self, charID, locationID, teamID, amount, activity):
     """
     Logs every bid on a team.
     """
     with ExceptionEater('eventLog'):
         self.eventLog.LogOwnerEvent(EVENT_BID_ON_TEAM, charID, locationID,
                                     teamID, amount, activity)
         self.eventLog.LogOwnerEventJson(EVENT_BID_ON_TEAM,
                                         charID,
                                         locationID,
                                         teamID=teamID,
                                         amount=amount,
                                         activity=activity)
예제 #21
0
def Initialize(getCohortFunction):
    """
        Initializes the gatekeeper modules method of resolving the proper service
        to use. Service must implement GetCohortsForCharacter.
    
        :params getCohortFunction: A function that will fetch cohorts for user base on
        a characterID
    """
    global GetCohortFunction
    with ExceptionEater('Gatekeeper has already been initialized!'):
        if not GetCohortFunction:
            GetCohortFunction = getCohortFunction
        else:
            raise RuntimeError('Gatekeeper has already been initialized!')
예제 #22
0
 def LogReimbursement(self, locationID, teamID, bidInfo, activity):
     """
     Logs for characters that lost a team auction.
     Puts a random charID as owner from the bid info.
     """
     with ExceptionEater('eventLog'):
         charID = bidInfo.keys()[0]
         bidList = self.GetBidsForSolarSystemAsText(bidInfo)
         self.eventLog.LogOwnerEvent(EVENT_REIMBURSE_LOSER, charID,
                                     locationID, teamID, bidList, activity)
         self.eventLog.LogOwnerEventJson(EVENT_REIMBURSE_LOSER,
                                         charID,
                                         locationID,
                                         teamID=teamID,
                                         bidList=bidList,
                                         activity=activity)
예제 #23
0
def CharacterIsInCohort(cohort, *args):
    """
        A simple utility function to keep code clean.
        This should be the only function you ever need to call.
    
        :param cohort: The cohorts unique identifier
        :param *args: any arguments required to resolve the bound GetCohortFunction call.
    """
    isInCohort = False
    with ExceptionEater(
            'Failed to query the gatekeeper. Returning False for querying entity.'
    ):
        CohortFunction = GetCohortFunction(args)
        isInCohort = cohort in _GetCohortsForCharacterFromService(
            CohortFunction)
    return isInCohort
예제 #24
0
def _ParseBannerFeed(feed):
    root = ElementTree.fromstring(feed)
    banners = []
    for element in root.findall('atom:entry',
                                namespaces=BANNER_FEED_NAMESPACES):
        with ExceptionEater('Failed to parse store banner element'):
            descriptionElement = element.find(
                'ccpmedia:group/ccpmedia:description',
                namespaces=BANNER_FEED_NAMESPACES)
            action = descriptionElement.text
            imageElement = element.find('ccpmedia:group/ccpmedia:content',
                                        namespaces=BANNER_FEED_NAMESPACES)
            imageUrl = imageElement.attrib['url']
            banners.append((imageUrl, action))

    return banners
예제 #25
0
 def PerformTrade(self, *args):
     useCorp = self.TradingForCorp()
     buyItemList, failedItems = self.GetValidatedAndFailedTypes()
     if not len(buyItemList):
         uicore.Message('uiwarning03')
         return
     if not self.ContinueAfterWarning(buyItemList):
         return
     with ExceptionEater():
         self.LogBuy(buyItemList)
     ordersCreated = sm.GetService('marketQuote').BuyMulti(
         self.baseStationID, buyItemList, useCorp)
     orderIDs = {order.orderID for order in ordersCreated}
     self.activeOrders.update(orderIDs)
     self.CreateNewBuyOrder(failedItems)
     self.VerifyExpiredOrders()
예제 #26
0
    def CreateComponentInstances(self, itemID, typeID):
        componentClassesForTypeID = self.typeIDToClassMapping[typeID]
        components = self._GetComponentsByItemId(itemID)
        for componentClass in componentClassesForTypeID:
            if componentClass.componentName in components:
                continue
            attributes = self.attributeLoader.GetAttributes(
                typeID, componentClass.componentName)
            with ExceptionEater('Error creating a component %s' %
                                componentClass.componentName):
                instance = componentClass.factoryMethod(
                    itemID, typeID, attributes, self)
                components[componentClass.componentName] = instance
                self.componentNameToItemIDs[
                    componentClass.componentName][itemID] = instance

        return components
예제 #27
0
    def _NameFetcher(self, nameQueue):
        """
        Waits for incoming name requests, then fetches them from the server in a single call.
        Results are returned by sending back to the requester's channel.
        """
        while self.state == SERVICE_RUNNING:
            with ExceptionEater('voucherCache._NameFetcher'):
                requests = {}
                voucherID, responseChannel = nameQueue.receive()
                requests[voucherID] = responseChannel
                while nameQueue.balance:
                    voucherID, responseChannel = nameQueue.receive()
                    requests[voucherID] = responseChannel

                self.PrimeVoucherNames(requests.keys())
                for voucherID, responseChannel in requests.iteritems():
                    responseChannel.send(self.names[voucherID])
 def IsInCohort(self, cohortID, *args):
     """
         A simple utility function that returns if an entity(user or character) belongs to a cohort
         It is cached until cache size runs out or TearDown is called
     
         :param cohort: The cohorts unique identifier
         :param *args: any arguments required to resolve the bound GetCohortFunction call.
     """
     if self.IsInitialized():
         isInCohort = False
         with ExceptionEater(
                 'Failed to query the gatekeeper. Returning False for querying entity.'
         ):
             CohortFunction = self.GetCohortFunction(args)
             isInCohort = cohortID in self._GetCohortsForEntityFromService(
                 CohortFunction)
         return isInCohort
     raise RuntimeError('Gatekeeper not initialized')
예제 #29
0
 def UpdateProbeResultBrackets(self):
     """
     Here we need to update the scan result with the latest signature scan results
     """
     updateSigData = set()
     for sigData in self.siteController.siteMaps.IterSitesByKey(SIGNATURE):
         with ExceptionEater('Updating signature overlay bracket'):
             result = self.scanSvc.GetResultForTargetID(sigData.targetID)
             if result is None:
                 continue
             if sigData.dungeonNameID is None:
                 dungeonNameID = result.get('dungeonNameID', None)
                 if dungeonNameID is not None:
                     sigData.dungeonNameID = dungeonNameID
                     updateSigData.add(sigData)
             if sigData.factionID is None:
                 factionID = result.get('factionID', None)
                 if factionID is not None:
                     sigData.factionID = factionID
                     updateSigData.add(sigData)
             if sigData.scanStrengthAttribute is None:
                 strengthAttributeID = result.get('strengthAttributeID',
                                                  None)
                 if strengthAttributeID is not None:
                     sigData.scanStrengthAttribute = strengthAttributeID
                     updateSigData.add(sigData)
             if result['certainty'] > sigData.signalStrength and isinstance(
                     result['data'], tuple):
                 sigData.signalStrength = result['certainty']
                 if result['certainty'] >= 1.0:
                     sigData.position = result['data']
                     bp = self.michelle.GetBallpark()
                     if bp is None:
                         raise InvalidClientStateError('ballpark not found')
                     if self.siteController.spaceLocations.ContainsSite(
                             sigData.siteID):
                         ball = self.siteController.spaceLocations.GetBySiteID(
                             sigData.siteID).ballRef()
                         bp.SetBallPosition(ball.id, *sigData.position)
                         self.siteController.NotifySiteChanged(sigData)
                 updateSigData.add(sigData)
         if updateSigData:
             for sigData_ in updateSigData:
                 self.UpdateScanData(sigData_)
예제 #30
0
    def CreateComponentInstances(self, itemID, typeID):
        if itemID in self.itemIDToComponentInstances:
            raise ComponentInstanceAlreadyExists(
                'itemID %s already exists. TypeID was %s' % (itemID, typeID))
        componentClassesForTypeID = self.typeIDToClassMapping[typeID]
        components = {}
        self.itemIDToComponentInstances[itemID] = components
        for componentClass in componentClassesForTypeID:
            attributes = self.attributeLoader.GetAttributes(
                typeID, componentClass.componentName)
            with ExceptionEater('Error creating a component %s' %
                                componentClass.componentName):
                instance = componentClass.factoryMethod(
                    itemID, typeID, attributes, self)
                components[componentClass.componentName] = instance
            self.componentNameToItemIDs[
                componentClass.componentName][itemID] = instance

        return components