コード例 #1
0
ファイル: server_api.py プロジェクト: lebedynskyi/FMV_server
def _safe_handle(handler, args):
    try:
        start_time = time.time()
        rez = handler.handle(args)
        json_response = json_utils.to_json("response", rez)

        request_time = time.time() - start_time

        response = make_response(json_response)
        response.headers['Request-time'] = str(request_time)

        return response
    except BaseException as e:
        if not isinstance(e, BaseFMSException):
            LOG.exception(e)
        return json_utils.to_json("error", InnerServerError(e.message))
コード例 #2
0
    def test_json_serializable(self):
        class JsonClass(json_utils.JsonSerializable):
            pass

        obj = JsonClass()
        json_utils.to_json("k", obj)
コード例 #3
0
    def test_json_serializable(self):
        class JsonClass(json_utils.JsonSerializable):
            pass

        obj = JsonClass()
        json_utils.to_json("k", obj)
コード例 #4
0
 def test_exception(self):
     exception = ValueError("test")
     expected = '{"resp": "test"}'
     self.assertEqual(json_utils.to_json("resp", exception), expected)
コード例 #5
0
 def test_exception(self):
     exception = ValueError("test")
     expected = '{"resp": "test"}'
     self.assertEqual(json_utils.to_json("resp", exception), expected)