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' 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 <[email protected]> > --- > 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 > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit
signature.asc
Description: Digital signature
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
