Skip to content

Commit 53f203a

Browse files
opikalosseliverstov
authored andcommitted
added proper handler for report_dir creation (via allure-framework#450)
1 parent d30b202 commit 53f203a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

allure-python-commons/src/logger.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import errno
12
import io
23
import os
34
import sys
@@ -16,13 +17,16 @@ class AllureFileLogger(object):
1617
def __init__(self, report_dir, clean=False):
1718
self._report_dir = report_dir
1819

19-
if not os.path.exists(report_dir):
20+
try:
2021
os.makedirs(report_dir)
21-
elif clean:
22-
for f in os.listdir(report_dir):
23-
f = os.path.join(report_dir, f)
24-
if os.path.isfile(f):
25-
os.unlink(f)
22+
except OSError as e:
23+
if e.errno != errno.EEXIST:
24+
raise
25+
elif clean:
26+
for f in os.listdir(report_dir):
27+
f = os.path.join(report_dir, f)
28+
if os.path.isfile(f):
29+
os.unlink(f)
2630

2731
def _report_item(self, item):
2832
indent = INDENT if os.environ.get("ALLURE_INDENT_OUTPUT") else None

0 commit comments

Comments
 (0)