use shutil.rmtree() instead of calling 'rm -rf' for increased portability

This commit is contained in:
Axel Kohlmeyer 2018-11-28 20:46:50 -05:00
parent a4d21370bf
commit eda79bd1c2
8 changed files with 20 additions and 30 deletions

View File

@ -143,8 +143,8 @@ fp.close()
if makeflag:
print("Building libgpu.a ...")
cmd = "rm -f libgpu.a"
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if os.path.exists("libgpu.a"):
os.remove("libgpu.a")
cmd = "make -f Makefile.auto clean; make -f Makefile.auto"
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
print(txt.decode('UTF-8'))

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess
import sys,os,re,subprocess,shutil
# help message
@ -177,8 +177,7 @@ if buildflag:
if os.path.isdir(kimdir):
print("kim-api is already installed at %s.\nRemoving it for re-install" % kimdir)
cmd = 'rm -rf "%s"' % kimdir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(kimdir)
# configure LAMMPS to use kim-api to be installed

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess,hashlib
import sys,os,re,subprocess,hashlib,shutil
# help message
@ -167,8 +167,7 @@ if buildflag:
print("Unpacking LATTE ...")
if os.path.exists(lattedir):
cmd = 'rm -rf "%s"' % lattedir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(lattedir)
cmd = 'cd "%s"; tar zxvf LATTE.tar.gz' % lattepath
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
os.remove("%s/LATTE.tar.gz" % lattepath)

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess
import sys,os,re,subprocess,shutil
# help message
@ -139,15 +139,13 @@ if buildflag:
print("Unpacking MS-CG tarfile ...")
if os.path.exists("%s/%s" % (homepath,tardir)):
cmd = 'rm -rf "%s/%s"' % (homepath,tardir)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree("%s/%s" % (homepath,tardir))
cmd = 'cd "%s"; tar -xzvf %s' % (homepath,tarfile)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
os.remove("%s/%s" % (homepath,tarfile))
if os.path.basename(homedir) != tardir:
if os.path.exists(homedir):
cmd = 'rm -rf "%s"' % homedir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(homedir)
os.rename("%s/%s" % (homepath,tardir),homedir)
# build MS-CG

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess,hashlib
import sys,os,re,subprocess,hashlib,shutil
# help message
@ -169,11 +169,9 @@ if buildflag:
print("Unpacking plumed2 source tarball ...")
if os.path.exists("%s/plumed-%s" % (homepath,version)):
cmd = 'rm -rf "%s/plumed-%s"' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree("%s/plumed-%s" % (homepath,version))
if os.path.exists(homedir):
cmd = 'rm -rf "%s"' % (homedir)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(homedir)
cmd = 'cd "%s"; tar -xzvf %s' % (homepath,filename)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
os.remove("%s/%s" % (homepath,filename))

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess
import sys,os,re,subprocess,shutil
# help message
@ -132,15 +132,13 @@ if buildflag:
print("Unpacking Scafacos tarball ...")
if os.path.exists("%s/%s" % (homepath,version)):
cmd = 'rm -rf "%s/%s"' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree("%s/%s" % (homepath,version))
cmd = 'cd "%s"; tar -xzvf %s.tar.gz' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
os.remove("%s/%s.tar.gz" % (homepath,version))
if os.path.basename(homedir) != version:
if os.path.exists(homedir):
cmd = 'rm -rf "%s"' % homedir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(homedir)
os.rename("%s/%s" % (homepath,version),homedir)
# build Scafacos

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,glob,subprocess
import sys,os,re,glob,subprocess,shutil
# help message
@ -139,7 +139,7 @@ if buildflag:
edir = glob.glob("%s/eigen-eigen-*" % homepath)
for one in edir:
if os.path.isdir(one):
subprocess.check_output('rm -rf "%s"' % one,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(one)
cmd = 'cd "%s"; tar -xzvf %s' % (homepath,tarball)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
edir = glob.glob("%s/eigen-eigen-*" % homepath)

View File

@ -4,7 +4,7 @@
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess
import sys,os,re,subprocess,shutil
# help message
@ -136,15 +136,13 @@ if buildflag:
print("Unpacking Voro++ tarball ...")
if os.path.exists("%s/%s" % (homepath,version)):
cmd = 'rm -rf "%s/%s"' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree("%s/%s" % (homepath,version))
cmd = 'cd "%s"; tar -xzvf %s.tar.gz' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
os.remove("%s/%s.tar.gz" % (homepath,version))
if os.path.basename(homedir) != version:
if os.path.exists(homedir):
cmd = 'rm -rf "%s"' % homedir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
shutil.rmtree(homedir)
os.rename("%s/%s" % (homepath,version),homedir)
# build Voro++