From baceb316d82eb30cd413204071625f1e2dae4a7f Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Sun, 1 Mar 2015 14:34:21 +0100 Subject: reproducible: common: catch OSError EEXISTS while creating directories in write_html_page() --- bin/reproducible_common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index edc43ef8..7782f623 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -12,6 +12,7 @@ import os import re import sys +import errno import sqlite3 import logging import argparse @@ -208,7 +209,11 @@ def write_html_page(title, body, destfile, noheader=False, style_note=False, noe html += html_footer.substitute(date=now) else: html += '\n' - os.makedirs(destfile.rsplit('/', 1)[0], exist_ok=True) + try: + os.makedirs(destfile.rsplit('/', 1)[0], exist_ok=True) + except OSError as e: + if e.errno != errno.EEXIST: # that's 'File exists' error (errno 17) + raise with open(destfile, 'w') as fd: fd.write(html) -- cgit v1.2.3-70-g09d2