summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authord3v53c <shitfi63@gmail.com>2020-09-14 04:28:19 -0700
committerd3v53c <shitfi63@gmail.com>2020-09-14 04:28:19 -0700
commit3bfbab1dae8937514867abe35b20ef9365328eda (patch)
treec937777f0fa974901d637204477d7c362ab66bad
parent975f8fcfdba56294bb190d745cdd449a52e633f4 (diff)
downloadswig-3bfbab1dae8937514867abe35b20ef9365328eda.tar.gz
cmd exec using subprocess rather than system calls
-rwxr-xr-xTools/mkdist.py17
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