[Piglit] [PATCH] framework: Fix resuming of previous runs

Dylan Baker baker.dylan.c at gmail.com
Fri Nov 15 08:51:42 PST 2013


On Friday, November 15, 2013 08:37:27 AM Dylan Baker wrote:
> On Thursday, November 14, 2013 06:03:54 PM Damien Lespiau wrote:
> > 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.
> > 
> > Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
> > ---
> > 
> >  framework/core.py | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/framework/core.py b/framework/core.py
> > index 2d5d0dc..9f153a3 100644
> > --- a/framework/core.py
> > +++ b/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
> >          #
> 
> This looks fine. I had implemented this when I did the status work, but then
> didn't think I needed it. Resume is not a commonly used feature obviously.
> 
> Reviewed-by: Dylan Baker <baker.dylan.c at gmail.com>

I went ahead and pushed this
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20131115/0f54185e/attachment.pgp>


More information about the Piglit mailing list