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

@ -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