[Piglit] [PATCH] framework: use formatted time values in the HTML report

Dylan Baker baker.dylan.c at gmail.com
Wed Feb 26 14:17:14 PST 2014


On Tuesday, February 25, 2014 18:50:21 Ken Phillis Jr wrote:
> On Tue, Feb 25, 2014 at 11:30 AM, Thomas Wood <thomas.wood at intel.com> wrote:
> > v2: fix some small style issues (Dylan Baker)
> > 
> > Signed-off-by: Thomas Wood <thomas.wood at intel.com>
> > ---
> > 
> >  framework/summary.py | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/framework/summary.py b/framework/summary.py
> > index 2fc16ce..b5539b8 100644
> > --- a/framework/summary.py
> > +++ b/framework/summary.py
> > @@ -25,6 +25,7 @@ import itertools
> > 
> >  import shutil
> >  import collections
> >  import tempfile
> > 
> > +from datetime import timedelta
> > 
> >  from mako.template import Template
> >  
> >  # a local variable status exists, prevent accidental overloading by
> >  renaming> 
> > @@ -379,7 +380,7 @@ class Summary:
> >              with open(path.join(destination, each.name, "index.html"), 
'w') as out:
> >                  out.write(testindex.render(name=each.name,
> > 
> > -                                           time=each.time_elapsed,
> > +                                           time=str(timedelta(0,
> > each.time_elapsed)),> 
> >                                             options=each.options,
> >                                             glxinfo=each.glxinfo,
> >                                             lspci=each.lspci))
> > 
> > @@ -401,6 +402,7 @@ class Summary:
> >                      with open(path.join(destination, each.name, key +
> >                      ".html"),
> >                      
> >                                'w') as out:
> > +                        time = value.get('time', 'None')
> 
> In this area I believe that it should be possible to determine if the
> value should be "None" or whatever the timedelta returns.
> 
> >                          out.write(testfile.render(
> >                          
> >                              testname=key,
> >                              status=value.get('result', 'None'),
> > 
> > @@ -410,7 +412,7 @@ class Summary:
> >                              # disapear at somepoint
> >                              env=value.get('environment', None),
> >                              returncode=value.get('returncode', 'None'),
> > 
> > -                            time=value.get('time', 'None'),
> > +                            time=time if time == 'None' else
> > str(timedelta(0, time)),
> I believe this line here can simply be left as time=time.

No, it cannot. left as just time it will return the amount of time as a float, 
rather than as a timedelta (which is in HH:MM:SS.MS form)

You could, however, drop time = value.get('time', 'None') and replace this 
line with:
time = 'None' if not value.get('time') else str(timedelta(0, value['time']))

Although, I'm not sure that's any better than what's already there.

> 
> >                              info=value.get('info', 'None'),
> >                              traceback=value.get('traceback', 'None'),
> >                              command=value.get('command', 'None'),
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- 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/20140226/f811bed0/attachment.pgp>


More information about the Piglit mailing list