From: Damien Lespiau Subject: [PATCH 09/23] piglit: Fix resuming of previous runs Date: Fri, 15 Nov 2013 16:33:26 +0000 Message-ID: <1384533220-20780-10-git-send-email-damien.lespiau@intel.com> References: <1384533220-20780-1-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 49149FB8ED for ; Fri, 15 Nov 2013 08:33:55 -0800 (PST) In-Reply-To: <1384533220-20780-1-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org When resuming and loading the partial JSON file from disk, the 'status' property is replaced by status.Status objects. When serializing back those objects, JSONEncoder is unhappy because it doesn't know how to serialize status.Status objects and gives up with exceptions like: TypeError: skip is not JSON serializable We can write a small subclass of JSONEncoder that knows about Status objects and use it to do the initial write back of the partial JSON file. This commit has been posted on the piglit ml: http://lists.freedesktop.org/archives/piglit/2013-November/008447.html Signed-off-by: Damien Lespiau --- piglit/framework/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/piglit/framework/core.py b/piglit/framework/core.py index e7767c2..e0fe46c 100644 --- a/piglit/framework/core.py +++ b/piglit/framework/core.py @@ -58,6 +58,11 @@ __all__ = ['Environment', 'Test', 'testBinDir'] +class PiglitJSONEncoder(json.JSONEncoder): + def default(self, o): + if isinstance(o, status.Status): + return str(o) + return json.JSONEncoder.default(self, o) class JSONWriter: ''' @@ -108,7 +113,7 @@ class JSONWriter: self.file = file self.__indent_level = 0 self.__inhibit_next_indent = False - self.__encoder = json.JSONEncoder(indent=self.INDENT) + self.__encoder = PiglitJSONEncoder(indent=self.INDENT) # self.__is_collection_empty # -- 1.8.3.1