コード例 #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)
コード例 #5
0
    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
ファイル: ship.py プロジェクト: nanxijw/Clara-Pretty-One-Dick
 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
ファイル: eventLogger.py プロジェクト: connoryang/1v1dec
 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
ファイル: gatekeeperClass.py プロジェクト: connoryang/1v1dec
 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
ファイル: voucherCache.py プロジェクト: connoryang/1v1dec
    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
ファイル: banners.py プロジェクト: connoryang/1v1dec
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
ファイル: buyMultiFromBase.py プロジェクト: connoryang/1v1dec
 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])
コード例 #28
0
 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