diff options
author | d3v53c <shitfi63@gmail.com> | 2020-09-14 04:28:19 -0700 |
---|---|---|
committer | d3v53c <shitfi63@gmail.com> | 2020-09-14 04:28:19 -0700 |
commit | 3bfbab1dae8937514867abe35b20ef9365328eda (patch) | |
tree | c937777f0fa974901d637204477d7c362ab66bad | |
parent | 975f8fcfdba56294bb190d745cdd449a52e633f4 (diff) | |
download | swig-3bfbab1dae8937514867abe35b20ef9365328eda.tar.gz |
cmd exec using subprocess rather than system calls
-rwxr-xr-x | Tools/mkdist.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 7116144a0..92c12d88b 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -8,6 +8,12 @@ def failed(): print("mkdist.py failed to complete") sys.exit(2) +def check_file_exists(path): + return os.path.isfile(path) + +def check_dir_exists(path): + return os.path.isdir(path) + import argparse parser = argparse.ArgumentParser(description="Build a SWIG distribution tarball swig-x.y.z.tar.gz") parser.add_argument("version", help="version string in format x.y.z") @@ -33,13 +39,18 @@ if dirname.lower() != dirname: # If directory and tarball exist, remove it print("Removing " + dirname) -os.system("rm -rf " + dirname) +if check_dir_exists(dirname): + subprocess.call(["rm", "-rf", dirname]) print("Removing " + dirname + ".tar if exists") -os.system("rm -f " + dirname + ".tar.gz") +filename = dirname + ".tar" +if check_file_exists(filename): + subprocess.call(["rm", "-rf", filename]) print("Removing " + dirname + ".tar.gz if exists") -os.system("rm -f " + dirname + ".tar") +filename += ".gz" +if check_file_exists(filename): + subprocess.call(["rm", "-rf", filename]) # Grab the code from git |