From 7081b93b8ed4f98c628400e05d22d0523f41a842 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 12:24:37 +0100 Subject: Fixing #16 - Adding support for custom config file in user directory --- minishell_test/sandbox.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'minishell_test/sandbox.py') diff --git a/minishell_test/sandbox.py b/minishell_test/sandbox.py index f10eacf..e5a1850 100644 --- a/minishell_test/sandbox.py +++ b/minishell_test/sandbox.py @@ -6,23 +6,21 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 13:48:07 by charles #+# #+# # -# Updated: 2021/02/05 14:54:37 by charles ### ########.fr # +# Updated: 2021/02/27 12:05:35 by cacharle ### ########.fr # # # # ############################################################################ # -import os -import glob import shutil import subprocess from contextlib import contextmanager -import minishell_test.config as config +from minishell_test import config def create(): """Create a new sandbox directory""" try: - os.mkdir(config.SANDBOX_PATH) + config.SANDBOX_DIR.mkdir(parents=True, exist_ok=True) except OSError: pass @@ -32,10 +30,10 @@ def remove(): Brute force rm -rf if clean removal doesn't work due to permissions. """ try: - shutil.rmtree(config.SANDBOX_PATH) + shutil.rmtree(config.SANDBOX_DIR) except PermissionError: - subprocess.run(["chmod", "777", *glob.glob(config.SANDBOX_PATH + "/*")], check=True) - subprocess.run(["rm", "-rf", config.SANDBOX_PATH], check=True) + subprocess.run(["chmod", "777", *config.SANDBOX_DIR.glob("*")], check=True) + shutil.rmtree(config.SANDBOX_DIR) except FileNotFoundError: pass -- cgit From c92f2be21c6be2d44cd836dd7f362e545b9a1a90 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sat, 27 Feb 2021 14:46:21 +0100 Subject: Added make_args and check_error_messages configuration options --- minishell_test/sandbox.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'minishell_test/sandbox.py') diff --git a/minishell_test/sandbox.py b/minishell_test/sandbox.py index e5a1850..980cfe7 100644 --- a/minishell_test/sandbox.py +++ b/minishell_test/sandbox.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 13:48:07 by charles #+# #+# # -# Updated: 2021/02/27 12:05:35 by cacharle ### ########.fr # +# Updated: 2021/02/27 12:32:17 by cacharle ### ########.fr # # # # ############################################################################ # @@ -42,5 +42,7 @@ def remove(): def context(): """Sandbox context manager""" create() - yield - remove() + try: + yield + finally: + remove() -- cgit