diff --git a/lib/kim/Install.py b/lib/kim/Install.py index 06479d2d4dd9480f0de8685f6b1535e61d240e0e..21ea859852904a00c8f2a5cc825f84adf0cdb8fd 100644 --- a/lib/kim/Install.py +++ b/lib/kim/Install.py @@ -60,8 +60,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt diff --git a/lib/mscg/Install.py b/lib/mscg/Install.py index e4e5ec5613c2b2f0c290df097b24dea8d257c11c..154f5aa5220e0a67c603f9edc56bdb44411681e8 100644 --- a/lib/mscg/Install.py +++ b/lib/mscg/Install.py @@ -47,8 +47,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt diff --git a/lib/smd/Install.py b/lib/smd/Install.py index 1c270bea5e8e824f3671044dfcef64666c38ebb1..00891339d0806d319fbbacb2602eff12dba329b0 100644 --- a/lib/smd/Install.py +++ b/lib/smd/Install.py @@ -47,8 +47,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index a4d07ac745b574bd97490a33ba6095e5262a4600..4998358d27af55447ecf880d960d180d9fdc8fac 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -46,8 +46,29 @@ def error(str=None): def fullpath(path): return os.path.abspath(os.path.expanduser(path)) +def which(program): + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + def geturl(url,fname): - cmd = 'curl -L -o "%s" %s' % (fname,url) + if which('curl') != None: + cmd = 'curl -L -o "%s" %s' % (fname,url) + elif which('wget') != None: + cmd = 'wget -O "%s" %s' % (fname,url) + else: error("cannot find 'wget' or 'curl' to download source code") txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) return txt