Exemple #1
0
def _requestWgniToken(callback):
    tokenRqs = getTokenRequester(TOKEN_TYPE.WGNI)

    def onCallback(response):
        if response and response.isValid():
            callback({
                'spa_id': str(response.getDatabaseID()),
                'token': response.getToken()
            })
        else:
            coolDownExpiration = tokenRqs.getReqCoolDown(
            ) - tokenRqs.lastResponseDelta()
            callback({
                'error':
                'Unable to obtain token.',
                'cooldown':
                coolDownExpiration
                if coolDownExpiration > 0 else tokenRqs.getReqCoolDown()
            })

    if not tokenRqs.isInProcess():
        tokenRqs.request(timeout=10.0)(onCallback)
    else:
        onCallback(response=None)
    return
Exemple #2
0
 def wgniToken(self, cmd):
     tokenRqs = getTokenRequester(TOKEN_TYPE.WGNI)
     if not tokenRqs.isInProcess():
         response = yield tokenRqs.request(timeout=10.0)
     else:
         response = None
     if response and response.isValid():
         yield {
             'request_id': 'token1',
             'spa_id': str(response.getDatabaseID()),
             'token': response.getToken()
         }
     else:
         coolDownExpiration = tokenRqs.getReqCoolDown(
         ) - tokenRqs.lastResponseDelta()
         yield {
             'request_id':
             'token1',
             'error':
             'Unable to obtain token.',
             'cooldown':
             coolDownExpiration
             if coolDownExpiration > 0 else tokenRqs.getReqCoolDown()
         }
     return
def getWgniToken(proxy, args, params, callback):
    def _cbWrapper(response):
        if response and response.isValid():
            callback(str(response.getToken()))
        else:
            callback('')

    from gui.shared.utils.requesters import getTokenRequester
    tokenRqs = getTokenRequester(constants.TOKEN_TYPE.WGNI)
    if not tokenRqs.isInProcess():
        tokenRqs.request(timeout=10.0)(_cbWrapper)
    else:
        _cbWrapper(response=None)
    return
Exemple #4
0
 def createTokenRequester(self):
     return getTokenRequester(TOKEN_TYPE.WGNI)