Switched to shutil
This commit is contained in:
parent
813eba5b1b
commit
27298f0f5f
1 changed files with 14 additions and 21 deletions
|
@ -1,4 +1,5 @@
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import configparser
|
import configparser
|
||||||
|
@ -43,28 +44,24 @@ if not work_dir.exists():
|
||||||
case_dir = work_dir.joinpath(config.get('main', 'case'))
|
case_dir = work_dir.joinpath(config.get('main', 'case'))
|
||||||
if case_dir.exists():
|
if case_dir.exists():
|
||||||
log.info(f'Deleting case ({case_dir})')
|
log.info(f'Deleting case ({case_dir})')
|
||||||
sp.run(
|
shutil.rmtree(case_dir)
|
||||||
('rm', '-r', case_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
log.info(f'Copying case ({input_dir} -> {case_dir})')
|
log.info(f'Copying case ({input_dir} -> {case_dir})')
|
||||||
sp.run(
|
shutil.copytree(input_dir, case_dir)
|
||||||
('cp', '-r', input_dir, case_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
if config.getboolean('stl', 'copy', fallback=False):
|
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')
|
stl_dir = case_dir.joinpath('constant', 'triSurface')
|
||||||
if stl_dir.exists():
|
if stl_dir.exists():
|
||||||
log.info(f'Deleting stl directory ({stl_dir})')
|
log.info(f'Deleting stl directory ({stl_dir})')
|
||||||
sp.run(
|
shutil.rmtree(stl_dir)
|
||||||
('rm', '-r', stl_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
stl_in = Path(config.get('stl', 'from')).expanduser()
|
|
||||||
log.info(f'Copying stl directory ({stl_in} -> {stl_dir})')
|
log.info(f'Copying stl directory ({stl_in} -> {stl_dir})')
|
||||||
sp.run(
|
shutil.copytree(stl_in, stl_dir)
|
||||||
('cp', '-r', stl_in, stl_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
if config.getboolean('blockMesh', 'enable', fallback=False):
|
if config.getboolean('blockMesh', 'enable', fallback=False):
|
||||||
log.info('Running blockMesh')
|
log.info('Running blockMesh')
|
||||||
|
@ -107,11 +104,9 @@ if config.getboolean('snappyHexMesh', 'enable', fallback=False):
|
||||||
log.info(f'snappyHexMesh finished successfully')
|
log.info(f'snappyHexMesh finished successfully')
|
||||||
|
|
||||||
log.info('Copying 0.org -> 0')
|
log.info('Copying 0.org -> 0')
|
||||||
sp.run(
|
shutil.copytree(
|
||||||
('cp', '-r',
|
case_dir.joinpath('0.org'),
|
||||||
case_dir.joinpath('0.org'),
|
case_dir.joinpath('0'),
|
||||||
case_dir.joinpath('0'),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if config.getboolean('setFields', 'enable', fallback=False):
|
if config.getboolean('setFields', 'enable', fallback=False):
|
||||||
|
@ -202,9 +197,7 @@ if config.getboolean('olaFlow', 'enable', fallback=False):
|
||||||
log.info(f'Deleting processor directories')
|
log.info(f'Deleting processor directories')
|
||||||
for proc_dir in case_dir.glob(r'processor*'):
|
for proc_dir in case_dir.glob(r'processor*'):
|
||||||
log.info(f'Deleting {proc_dir}')
|
log.info(f'Deleting {proc_dir}')
|
||||||
sp.run(
|
shutil.rmtree(proc_dir)
|
||||||
('rm', '-r', proc_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
_t1 = time()
|
_t1 = time()
|
||||||
log.info(f'Program ended successfully after {timedelta(seconds=_t1-_t0)}')
|
log.info(f'Program ended successfully after {timedelta(seconds=_t1-_t0)}')
|
||||||
|
|
Reference in a new issue