[tools] Remove in-house 'which' now that we have py3

This commit is contained in:
Ebrahim Byagowi 2020-03-18 23:58:20 +03:30
parent a0c58be371
commit b5526a09ff
4 changed files with 9 additions and 79 deletions

View File

@ -1,24 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys, os, subprocess, tempfile, threading import sys, os, subprocess, tempfile, threading, shutil
def which (program):
# https://stackoverflow.com/a/377028
def is_exe (fpath):
return os.path.isfile (fpath) and os.access (fpath, os.X_OK)
fpath, _ = os.path.split (program)
if fpath:
if is_exe (program):
return program
else:
for path in os.environ["PATH"].split (os.pathsep):
exe_file = os.path.join (path, program)
if is_exe (exe_file):
return exe_file
return None
def cmd (command): def cmd (command):
@ -74,7 +56,7 @@ fails = 0
libtool = os.environ.get ('LIBTOOL') libtool = os.environ.get ('LIBTOOL')
valgrind = None valgrind = None
if os.environ.get ('RUN_VALGRIND', ''): if os.environ.get ('RUN_VALGRIND', ''):
valgrind = which ('valgrind') valgrind = shutil.which ('valgrind')
if valgrind is None: if valgrind is None:
print ("""Valgrind requested but not found.""") print ("""Valgrind requested but not found.""")
sys.exit (1) sys.exit (1)

View File

@ -1,24 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys, os, subprocess, tempfile, threading import sys, os, subprocess, tempfile, threading, shutil
def which (program):
# https://stackoverflow.com/a/377028
def is_exe (fpath):
return os.path.isfile (fpath) and os.access (fpath, os.X_OK)
fpath, _ = os.path.split (program)
if fpath:
if is_exe (program):
return program
else:
for path in os.environ["PATH"].split (os.pathsep):
exe_file = os.path.join (path, program)
if is_exe (exe_file):
return exe_file
return None
def cmd (command): def cmd (command):
@ -74,7 +56,7 @@ fails = 0
libtool = os.environ.get ('LIBTOOL') libtool = os.environ.get ('LIBTOOL')
valgrind = None valgrind = None
if os.environ.get ('RUN_VALGRIND', ''): if os.environ.get ('RUN_VALGRIND', ''):
valgrind = which ('valgrind') valgrind = shutil.which ('valgrind')
if valgrind is None: if valgrind is None:
print ("""Valgrind requested but not found.""") print ("""Valgrind requested but not found.""")
sys.exit (1) sys.exit (1)

View File

@ -1,24 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys, os, subprocess, tempfile, threading import sys, os, subprocess, tempfile, threading, shutil
def which(program):
# https://stackoverflow.com/a/377028
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, _ = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def cmd(command): def cmd(command):
@ -74,7 +56,7 @@ fails = 0
libtool = os.environ.get('LIBTOOL') libtool = os.environ.get('LIBTOOL')
valgrind = None valgrind = None
if os.environ.get('RUN_VALGRIND', ''): if os.environ.get('RUN_VALGRIND', ''):
valgrind = which ('valgrind') valgrind = shutil.which ('valgrind')
if valgrind is None: if valgrind is None:
print ("""Valgrind requested but not found.""") print ("""Valgrind requested but not found.""")
sys.exit (1) sys.exit (1)

View File

@ -10,28 +10,12 @@ import re
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
import shutil
from subset_test_suite import SubsetTestSuite from subset_test_suite import SubsetTestSuite
# https://stackoverflow.com/a/377028 fonttools = shutil.which ("fonttools")
def which (program): ots_sanitize = shutil.which ("ots-sanitize")
def is_exe (fpath):
return os.path.isfile (fpath) and os.access (fpath, os.X_OK)
fpath, _ = os.path.split (program)
if fpath:
if is_exe (program):
return program
else:
for path in os.environ["PATH"].split (os.pathsep):
exe_file = os.path.join (path, program)
if is_exe (exe_file):
return exe_file
return None
fonttools = which ("fonttools")
ots_sanitize = which ("ots-sanitize")
if not fonttools: if not fonttools:
print ("fonttools is not present, skipping test.") print ("fonttools is not present, skipping test.")