auth-test.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:guernsey 作者: ingnil 项目源码 文件源码
def getJson(self, request):
        deferred = self.prepareProcessList()

        def cb(processes):
            self.logger.debug("getJson() cb(%r)", processes)
            request.write(json.dumps({"processes": processes}))
            request.finish()

        def eb(failure):
            self.logger.debug("getJson() eb(%r)", failure)
            if isinstance(failure.type, Exception):
                util.logTwistedFailure(self.logger, failure,
                                       "Exception thrown while getting process list")
            self.serverError(request)
            request.write(json.dumps({"error": "500 Internal Server Error"}))
            request.finish()

        deferred.addCallbacks(cb, eb)
        return server.NOT_DONE_YET

#
# Create a resource class for processes owned by the user root. It
# will produce HTML and JSON. This class inherits everything from the
# ProcessesResource created above, but substitutes the
# LineReceiverProtocol for a FilteredLineReceiverProtocol
# instead. This resource just illustrates the use of that class.
#
# Note that we also reuse the template file from the parent class. If
# we did not specify it here, the framework would try to use our class
# name to construct a template filename, and no such template exists.
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号