[Piglit] [PATCH] json.py: don't rename the results file when updating results version
Dylan Baker
baker.dylan.c at gmail.com
Tue Apr 21 14:35:42 PDT 2015
On Tue, Apr 21, 2015 at 11:06:16AM -0700, Dylan Baker wrote:
> I think you're trying to handle a case that can't (or maybe shouldn't)
> happen.
>
> _update_results is a helper called only by load_results, which always
> passes in a filename, so I think that in every case you'd end up hitting
> the isfile path. In fact, I've added an 'assert
> os.path.isfile(filepath)' and run the unit tests and get no failures.
>
> I'd actually been thinking about doing this myself, I think though all
> we need to do is replace the 'results.json.old' with filedir + '.old'
err, that should be filename + '.old'
>
> Dylan
>
> On Tue, Apr 21, 2015 at 10:50:50AM +0100, Thomas Wood wrote:
> > Keep the existing results file name if the results input was a file
> > rather than a directory.
> >
> > Signed-off-by: Thomas Wood <thomas.wood at intel.com>
> > ---
> > framework/backends/json.py | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/framework/backends/json.py b/framework/backends/json.py
> > index affd64e..2fedd13 100644
> > --- a/framework/backends/json.py
> > +++ b/framework/backends/json.py
> > @@ -296,10 +296,14 @@ def _update_results(results, filepath):
> > results = loop_updates(results)
> >
> > # Move the old results, and write the current results
> > - filedir = os.path.dirname(filepath)
> > try:
> > - os.rename(filepath, os.path.join(filedir, 'results.json.old'))
> > - _write(results, os.path.join(filedir, 'results.json'))
> > + if os.path.isfile(filepath):
> > + os.rename(filepath, filepath + '.old')
> > + _write(results, filepath)
> > + else:
> > + filedir = os.path.dirname(filepath)
> > + os.rename(filepath, os.path.join(filedir, 'results.json.old'))
> > + _write(results, os.path.join(filedir, 'results.json'))
> > except OSError:
> > print("WARNING: Could not write updated results {}".format(filepath),
> > file=sys.stderr)
> > --
> > 2.1.0
> >
> > _______________________________________________
> > 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: 473 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150421/73b319c1/attachment.sig>
More information about the Piglit
mailing list