Switched to shutil

This commit is contained in:
Edgar P. Burkhart 2022-01-23 14:13:36 +01:00
parent 813eba5b1b
commit 27298f0f5f
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -1,4 +1,5 @@
import sys
import shutil
import argparse
import logging
import configparser
@ -43,28 +44,24 @@ 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})')
sp.run(
('rm', '-r', case_dir)
)
shutil.rmtree(case_dir)
log.info(f'Copying case ({input_dir} -> {case_dir})')
sp.run(
('cp', '-r', input_dir, case_dir)
)
shutil.copytree(input_dir, case_dir)
if config.getboolean('stl', 'copy', fallback=False):
stl_in = Path(config.get('stl', 'from')).expanduser()
if not stl_in.exists():
log.error(f'STL from directory does not exist ({stl_in})')
sys.exit(1)
stl_dir = case_dir.joinpath('constant', 'triSurface')
if stl_dir.exists():
log.info(f'Deleting stl directory ({stl_dir})')
sp.run(
('rm', '-r', stl_dir)
)
shutil.rmtree(stl_dir)
stl_in = Path(config.get('stl', 'from')).expanduser()
log.info(f'Copying stl directory ({stl_in} -> {stl_dir})')
sp.run(
('cp', '-r', stl_in, stl_dir)
)
shutil.copytree(stl_in, stl_dir)
if config.getboolean('blockMesh', 'enable', fallback=False):
log.info('Running blockMesh')
@ -107,11 +104,9 @@ if config.getboolean('snappyHexMesh', 'enable', fallback=False):
log.info(f'snappyHexMesh finished successfully')
log.info('Copying 0.org -> 0')
sp.run(
('cp', '-r',
shutil.copytree(
case_dir.joinpath('0.org'),
case_dir.joinpath('0'),
)
)
if config.getboolean('setFields', 'enable', fallback=False):
@ -202,9 +197,7 @@ 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}')
sp.run(
('rm', '-r', proc_dir)
)
shutil.rmtree(proc_dir)
_t1 = time()
log.info(f'Program ended successfully after {timedelta(seconds=_t1-_t0)}')