summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2016-03-04 16:25:16 -0800
committerDylan Baker <dylan@pnwbakers.com>2016-06-01 07:08:43 -0700
commitaef20f2edd237ef1a6d98d5ce56ef0b3a96ba038 (patch)
tree0143524e0875d19426c35a9bb233e8d78233a28c /framework
parentadf3b59fd3fff3b98742dde97353389ff9f7b949 (diff)
framework/summary/html_.py: use core.check_dir
This just reduces some code duplication. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/summary/html_.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/framework/summary/html_.py b/framework/summary/html_.py
index 80bee82e0..f7fdc8576 100644
--- a/framework/summary/html_.py
+++ b/framework/summary/html_.py
@@ -38,7 +38,7 @@ import six
# a local variable status exists, prevent accidental overloading by renaming
# the module
-from framework import backends, exceptions
+from framework import backends, exceptions, core
from .common import Results, escape_filename, escape_pathname
from .feature import FeatResults
@@ -85,16 +85,13 @@ def _make_testrun_info(results, destination, exclude=None):
for each in results.results:
name = escape_pathname(each.name)
try:
- os.mkdir(os.path.join(destination, name))
- except OSError as e:
- if e.errno == errno.EEXIST:
- raise exceptions.PiglitFatalError(
- 'Two or more of your results have the same "name" '
- 'attribute. Try changing one or more of the "name" '
- 'values in your json files.\n'
- 'Duplicate value: {}'.format(name))
- else:
- raise e
+ core.check_dir(os.path.join(destination, name), True)
+ except exceptions.PiglitException:
+ raise exceptions.PiglitFatalError(
+ 'Two or more of your results have the same "name" '
+ 'attribute. Try changing one or more of the "name" '
+ 'values in your json files.\n'
+ 'Duplicate value: {}'.format(name))
with open(os.path.join(destination, name, "index.html"), 'wb') as out:
out.write(_TEMPLATES.get_template('testrun_info.mako').render(
@@ -114,11 +111,7 @@ def _make_testrun_info(results, destination, exclude=None):
temp_path = os.path.dirname(html_path)
if value.result not in exclude:
- # os.makedirs is very annoying, it throws an OSError if
- # the path requested already exists, so do this check to
- # ensure that it doesn't
- if not os.path.exists(temp_path):
- os.makedirs(temp_path)
+ core.check_dir(temp_path)
with open(html_path, 'wb') as out:
out.write(_TEMPLATES.get_template(