Exemple #1
0
 def __init__(self):
     super(DataRequestsByIDProcessor, self).__init__(Int32IDGenerator())
Exemple #2
0
 def __init__(self, sender=None, responseClass=None, idsGenerator=None):
     super(ClientRequestsByIDProcessor,
           self).__init__(idsGenerator=idsGenerator or Int32IDGenerator())
     self.__responseClass = responseClass or Response
     self._sender = sender
Exemple #3
0
 def __init__(self):
     super(_AvatarRequester, self).__init__(Int32IDGenerator())
Exemple #4
0
 def __init__(self):
     super(ClubRequester, self).__init__(Int32IDGenerator())
class PromoLogger(IPromoLogger):
    __PARAMS_MAP = {'action': {'set': PromoLogActions.ALL()},
     'type': {'set': PromoLogSubjectType.ALL(),
              'default': PromoLogSubjectType.TEASER},
     'teaserid': {},
     'slug': {},
     'spaid': {'default': _getPlayerDatabaseID},
     'time': {'default': time_utils.getCurrentTimestamp},
     'success': {},
     'lang': {'default': getLanguageCode},
     'source': {'set': PromoLogSourceType.ALL()},
     'url': {}}
    __TEASER_PARAMS_MAP = {'promoID': 'teaserid',
     'url': 'url',
     'slug': 'slug'}
    __lobbyContext = dependency.descriptor(ILobbyContext)
    __webController = dependency.descriptor(IWebController)
    __ANSWER_WAITING_TIME = 30
    __IDGenerator = Int32IDGenerator()

    def __init__(self):
        self.__requestIDs = {}

    @process
    def logAction(self, **kwargs):
        if self.__isEnabled():
            ctx = PromoSendActionLogCtx(self.__packData(kwargs))
            yield self.__webController.sendRequest(ctx=ctx)

    def logTeaserAction(self, teaserData, **kwargs):
        dataToSend = kwargs.copy()
        if teaserData:
            for sourceName, targetName in self.__TEASER_PARAMS_MAP.iteritems():
                dataToSend[targetName] = teaserData.get(sourceName)

        self.logAction(**dataToSend)

    def getLoggingFuture(self, teaserData=None, **kwargs):
        if not self.__isEnabled():
            return None
        else:
            requestID = self.__IDGenerator.next()
            callbackID = BigWorld.callback(self.__ANSWER_WAITING_TIME, partial(self.__sendDelayed, teaserData, requestID, **kwargs))
            self.__requestIDs[requestID] = callbackID
            return partial(self.__sendDelayed, teaserData, requestID, callbackID, **kwargs)

    def fini(self):
        for requestID, callbackID in self.__requestIDs.items():
            BigWorld.cancelCallback(callbackID)
            del self.__requestIDs[requestID]

    def __isEnabled(self):
        return self.__lobbyContext.getServerSettings().isPromoLoggingEnabled()

    def __sendDelayed(self, teaserData, requestID, callbackID=None, **kwargs):
        if requestID in self.__requestIDs:
            del self.__requestIDs[requestID]
            if callbackID is not None:
                BigWorld.cancelCallback(callbackID)
            success = kwargs.pop('success', None)
            if teaserData is not None:
                self.logTeaserAction(teaserData, success=success, **kwargs)
            else:
                self.logAction(success=success, **kwargs)
        return

    def __packData(self, data):
        result = {}
        for paramName, settings in self.__PARAMS_MAP.iteritems():
            if paramName in data:
                value = data[paramName]
                possibleValues = settings.get('set')
                if possibleValues and value not in possibleValues:
                    _logger.error('Wrong value for enumerable %s', paramName)
                    continue
                result[paramName] = value
            if 'default' in settings:
                default = settings['default']
                result[paramName] = default() if callable(default) else default

        return result
# Embedded file name: scripts/client/gui/shared/view_helpers/blur_manager.py
import logging
import weakref
import typing
from collections import deque
import GUI
from gui.app_loader import sf_lobby, sf_battle
from helpers import dependency
from ids_generators import Int32IDGenerator
from shared_utils import findFirst
from skeletons.account_helpers.settings_core import ISettingsCore
if typing.TYPE_CHECKING:
    from Math import Vector4
_DEFAULT_BLUR_ANIM_REPEAT_COUNT = 10
_logger = logging.getLogger(__name__)
_idsGenerator = Int32IDGenerator()


class CachedBlur(object):
    __slots__ = ('_blurId', '_enabled', '_fadeTime', '_rectangles',
                 '_ownLayer', '_layers', '_blurAnimRepeatCount', '__weakref__')

    def __init__(self,
                 enabled=False,
                 fadeTime=0,
                 ownLayer=None,
                 layers=None,
                 blurAnimRepeatCount=_DEFAULT_BLUR_ANIM_REPEAT_COUNT):
        self._blurId = next(_idsGenerator)
        self._rectangles = {}
        self._enabled = enabled