From 904a033ae738e1c351f8fef71e2ec2418fc4db3d Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 5 Feb 2021 12:27:32 +0100 Subject: Renaming src -> minishell_test for package name, Renaming main.py -> __main__.py for package execution with python -m --- src/sandbox.py | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 src/sandbox.py (limited to 'src/sandbox.py') diff --git a/src/sandbox.py b/src/sandbox.py deleted file mode 100644 index bd49d1e..0000000 --- a/src/sandbox.py +++ /dev/null @@ -1,48 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# sandbox.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: charles +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/09/11 13:48:07 by charles #+# #+# # -# Updated: 2021/01/31 03:59:30 by charles ### ########.fr # -# # -# ############################################################################ # - -import os -import glob -import shutil -import subprocess -from contextlib import contextmanager - -import config - - -def create(): - """Create a new sandbox directory""" - try: - os.mkdir(config.SANDBOX_PATH) - except OSError: - pass - - -def remove(): - """Remove the sandbox directory - Brute force rm -rf if clean removal doesn't work due to permissions. - """ - try: - shutil.rmtree(config.SANDBOX_PATH) - except PermissionError: - subprocess.run(["chmod", "777", *glob.glob(config.SANDBOX_PATH + "/*")], check=True) - subprocess.run(["rm", "-rf", config.SANDBOX_PATH], check=True) - except FileNotFoundError: - pass - - -@contextmanager -def context(): - """Sandbox context manager""" - create() - yield - remove() -- cgit