use distutils.spawn.find_executable

This commit is contained in:
j 2016-02-06 12:29:40 +05:30
parent e96847a3f4
commit 8b06842acc

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import division, with_statement, print_function from __future__ import division, with_statement, print_function
import distutils.spawn
from contextlib import closing from contextlib import closing
import json import json
import os import os
@ -8,7 +9,6 @@ import sys
import tarfile import tarfile
from urllib.request import urlopen from urllib.request import urlopen
from threading import Thread from threading import Thread
import subprocess
def makedirs(dirname): def makedirs(dirname):
if not os.path.exists(dirname): if not os.path.exists(dirname):
@ -163,7 +163,8 @@ class Install(Thread):
return self.base_url + url return self.base_url + url
def has_bin(cmd): def has_bin(cmd):
return subprocess.call(['which', cmd], stdout=subprocess.PIPE) == 0 path = distutils.spawn.find_executable(cmd)
return path != None
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) == 1: if len(sys.argv) == 1: