[Piglit] [PATCH] json.py: don't rename the results file when updating results version
Thomas Wood
thomas.wood at intel.com
Tue Apr 21 02:50:50 PDT 2015
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
More information about the Piglit
mailing list