From 3520843a6e2e3ab42332413813d3feeb4fa68177 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Sun, 23 Jan 2022 13:38:06 +0100 Subject: [PATCH] Removed distutils --- openfoam/run/__main__.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/openfoam/run/__main__.py b/openfoam/run/__main__.py index d157929..900b9e6 100644 --- a/openfoam/run/__main__.py +++ b/openfoam/run/__main__.py @@ -8,7 +8,6 @@ from time import time from datetime import timedelta from pathlib import Path -from distutils import dir_util import subprocess as sp _t0 = time() @@ -43,25 +42,27 @@ if not work_dir.exists(): case_dir = work_dir.joinpath(config.get('main', 'case')) if case_dir.exists(): log.info(f'Deleting case ({case_dir})') - dir_util.remove_tree(str(case_dir)) + sp.run( + ('rm', '-r', case_dir) + ) log.info(f'Copying case ({input_dir} -> {case_dir})') -dir_util.copy_tree( - str(input_dir), - str(case_dir), +sp.run( + ('cp', '-r', input_dir, case_dir) ) if config.getboolean('stl', 'copy', fallback=False): stl_dir = case_dir.joinpath('constant', 'triSurface') if stl_dir.exists(): log.info(f'Deleting stl directory ({stl_dir})') - dir_util.remove_tree(str(stl_dir)) + sp.run( + ('rm', '-r', stl_dir) + ) stl_in = Path(config.get('stl', 'from')) log.info(f'Copying stl directory ({stl_in} -> {stl_dir})') - dir_util.copy_tree( - str(stl_in), - str(stl_dir), + sp.run( + ('cp', '-r', stl_in, stl_dir) ) if config.getboolean('blockMesh', 'enable', fallback=False): @@ -105,9 +106,11 @@ if config.getboolean('snappyHexMesh', 'enable', fallback=False): log.info(f'snappyHexMesh finished successfully') log.info('Copying 0.org -> 0') -dir_util.copy_tree( - str(case_dir.joinpath('0.org')), - str(case_dir.joinpath('0')), +sp.run( + ('cp', '-r', + case_dir.joinpath('0.org'), + case_dir.joinpath('0'), + ) ) if config.getboolean('setFields', 'enable', fallback=False): @@ -198,7 +201,9 @@ if config.getboolean('olaFlow', 'enable', fallback=False): log.info(f'Deleting processor directories') for proc_dir in case_dir.glob(r'processor*'): log.info(f'Deleting {proc_dir}') - dir_util.remove_tree(str(proc_dir)) + sp.run( + ('rm', '-r', proc_dir) + ) _t1 = time() log.info(f'Program ended successfully after {timedelta(seconds=_t1-_t0)}')