Exemple #1
0
 def callback(result):
     skills = client.world.player.skills
     if skills is not None:
         d.callback(skills)
     else:
         defer.errback(NoSkills())
     return result
Exemple #2
0
    def onListGot(self, result):
        data = json.loads(result['data'])
        defer = self.defers['updateList']

        if data['r'] == 0:
            songs = data['song']
            for song in songs:
                self.musics.append(Music(song))

            # callback
            defer.callback(songs)
        else:
            # errback
            defer.errback(Exception('List data got an error: %s' % data['err']))
Exemple #3
0
    def execute(self, req, keyspace=None):
        if self.my_proto is None:
            return defer.errback(error.ConnectionClosed(
                                    'Lost connection before %s request could be made'
                                    % (req.method,)))
        method = getattr(self.my_proto.client, req.method, None)
        if method is None:
            raise InvalidThriftRequest("don't understand %s request" % req.method)

        d = defer.succeed(0)

        if req.method == 'set_keyspace':
            newksname = req.args[0]
            d.addCallback(lambda _: method(newksname))
            d.addCallback(self.store_successful_keyspace_set, newksname)
        else:
            if keyspace is not None and keyspace != self.keyspace:
                d.addCallback(lambda _: self.my_set_keyspace(keyspace))
            d.addCallback(lambda _: method(*req.args))
        return d
Exemple #4
0
    def execute(self, req, keyspace=None):
        if self.my_proto is None:
            return defer.errback(
                error.ConnectionClosed(
                    'Lost connection before %s request could be made' %
                    (req.method, )))
        method = getattr(self.my_proto.client, req.method, None)
        if method is None:
            raise InvalidThriftRequest("don't understand %s request" %
                                       req.method)

        d = defer.succeed(0)

        if req.method == 'set_keyspace':
            newksname = req.args[0]
            d.addCallback(lambda _: method(newksname))
            d.addCallback(self.store_successful_keyspace_set, newksname)
        else:
            if keyspace is not None and keyspace != self.keyspace:
                d.addCallback(lambda _: self.my_set_keyspace(keyspace))
            args = translateArgs(req, self.api_version)
            d.addCallback(lambda _: method(*args))
            d.addCallback(lambda results: postProcess(results, req.method))
        return d
Exemple #5
0
 def stop(result):
     if result == "OK":
         reactor.callLater(5, self.stop)
     else:
         defer.errback(Exception("Unable to shut down H-Cube"))
Exemple #6
0
 def _(i):
     try:
         return defer.succeed(p(i))
     except:
         return defer.errback(failure.Failure())
Exemple #7
0
 def callback(result):
     if skill in result:
         d.callback(result[skill])
     else:
         defer.errback(NoSkills())
     return result
Exemple #8
0
		def stop (result):
			if result == "OK":
				reactor.callLater(5, self.stop)
			else:
				defer.errback(Exception("Unable to shut down H-Cube"))
Exemple #9
0
 def _(i):
     try:
         return defer.succeed(p(i))
     except:
         return defer.errback(failure.Failure())