コード例 #1
0
ファイル: manager.py プロジェクト: acheraime/starpy
 def onEvent(event):
     if event.get('response') == 'Error':
         df.errback(error.AMICommandFailure(event))
     elif event.get('event') == stopEvent:
         df.callback(cache)
     else:
         cache.append(event)
コード例 #2
0
    def errorUnlessResponse(self, message, expected='Success'):
        """Raise AMICommandFailure error unless message['response'] == expected

        If == expected, returns the message
        """
        if type(message) is dict and message['response'] != expected:
            raise error.AMICommandFailure(message)
        return message
コード例 #3
0
 def sendResponse(challenge):
     if not type(challenge) is dict or not 'challenge' in challenge:
         raise error.AMICommandFailure(challenge)
     key_value = md5('%s%s' % (challenge['challenge'], self.factory.secret)).hexdigest()
     return self.sendDeferred({
         'action': 'Login',
         'authtype': 'MD5',
         'username': self.factory.username,
         'key': key_value,
     }).addCallback(self.errorUnlessResponse)
コード例 #4
0
 def extractVariable(message):
     """When message comes in, extract the variable from it"""
     if variable.lower() in message:
         value = message[variable.lower()]
     elif 'value' in message:
         value = message['value']
     else:
         raise error.AMICommandFailure(message)
     if value == '(null)':
         value = None
     return value
コード例 #5
0
 def onComplete(message):
     """Check for success, errback or callback as appropriate"""
     if not message['response'] == 'Success':
         log.info('Login Failure: %s', message)
         self.transport.loseConnection()
         self.factory.loginDefer.errback(
             error.AMICommandFailure("Unable to connect to manager",
                                     message))
     else:
         # XXX messy here, would rather have the factory trigger its own
         # callback...
         log.info('Login Complete: %s', message)
         self.factory.loginDefer.callback(self, )