diff --git a/_unittests/ut_helpgen/test_notebooks.py b/_unittests/ut_helpgen/test_notebooks.py index bbcc31843..5b4de54c6 100644 --- a/_unittests/ut_helpgen/test_notebooks.py +++ b/_unittests/ut_helpgen/test_notebooks.py @@ -23,6 +23,7 @@ from src.pyquickhelper.loghelper.flog import fLOG, run_cmd from src.pyquickhelper.helpgen.sphinx_main import process_notebooks, add_notebook_page +from src.pyquickhelper import get_temp_folder if sys.version_info[0] == 2: from codecs import open @@ -50,12 +51,8 @@ def test_notebook(self): nb = os.path.join(fold, "example_pyquickhelper.ipynb") assert os.path.exists(nb) - temp = os.path.join(path, "temp_nb") - if not os.path.exists(temp): - os.mkdir(temp) - for file in os.listdir(temp): - os.remove(os.path.join(temp, file)) - + temp = get_temp_folder(__file__, "temp_nb") + if sys.platform.startswith("win"): p1 = r"C:\Program Files\MiKTeX 2.9\miktex\bin\x64" p2 = r"%USERPROFILE%\AppData\Local\Pandoc" diff --git a/src/pyquickhelper/helpgen/process_notebooks.py b/src/pyquickhelper/helpgen/process_notebooks.py index 597806afd..fe5ab12e6 100644 --- a/src/pyquickhelper/helpgen/process_notebooks.py +++ b/src/pyquickhelper/helpgen/process_notebooks.py @@ -167,9 +167,6 @@ def process_notebooks(notebooks, if not os.path.exists(build_slide): os.mkdir(build_slide) - # for some reason, sometimes, the folder is not in write mode - change_file_status(build_slide) - if "WinPython" in sys.executable: # pip, or any program in Scripts cannot find python.exe # for the distribution WinPython diff --git a/src/pyquickhelper/pycode/utils_tests.py b/src/pyquickhelper/pycode/utils_tests.py index 924ba5f61..b3e28ef2e 100644 --- a/src/pyquickhelper/pycode/utils_tests.py +++ b/src/pyquickhelper/pycode/utils_tests.py @@ -8,6 +8,7 @@ from __future__ import print_function import os +import stat import sys import glob import re @@ -48,12 +49,20 @@ def get_temp_folder(thisfile, name, clean=True, create=True): if not os.path.exists(local): if create: os.mkdir(local) + mode = os.stat(local).st_mode + nmode = mode | stat.S_IWRITE + if nmode != mode: + os.chmod(local, nmode) else: if clean: remove_folder(local) time.sleep(0.1) if create and not os.path.exists(local): os.mkdir(local) + mode = os.stat(local).st_mode + nmode = mode | stat.S_IWRITE + if nmode != mode: + os.chmod(local, nmode) return local