diff --git a/lib/kim/Install.py b/lib/kim/Install.py index 21ea859852904a00c8f2a5cc825f84adf0cdb8fd..aa244ee6eabd0f1296c1f39fd74639aab9f021dc 100644 --- a/lib/kim/Install.py +++ b/lib/kim/Install.py @@ -6,6 +6,8 @@ from __future__ import print_function import sys,os,re,subprocess +# help message + help = """ Syntax from src dir: make lib-kim args="-b -v version -a kim-name" or: make lib-kim args="-b -a everything" @@ -23,7 +25,7 @@ specify one or more options, order does not matter -b = download and build base KIM API library with example Models this will delete any previous installation in the current folder -n = do NOT download and build base KIM API library. - Use an existing installation + Use an existing installation -p = specify location of KIM API installation (implies -n) -a = add single KIM model or model driver with kim-name to existing KIM API lib (see example below). @@ -78,13 +80,27 @@ def which(program): return None def geturl(url,fname): + success = False + if which('curl') != None: cmd = 'curl -L -o "%s" %s' % (fname,url) - elif which('wget') != None: + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling curl failed with: %s" % e.output.decode('UTF-8')) + + if not success and 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 + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling wget failed with: %s" % e.output.decode('UTF-8')) + + if not success: + error("Failed to download source code with 'curl' or 'wget'") + return # parse args diff --git a/lib/mscg/Install.py b/lib/mscg/Install.py index 154f5aa5220e0a67c603f9edc56bdb44411681e8..76c986ef6d5f2409c448f7eeaec92d1e06d759b3 100644 --- a/lib/mscg/Install.py +++ b/lib/mscg/Install.py @@ -65,13 +65,27 @@ def which(program): return None def geturl(url,fname): + success = False + if which('curl') != None: cmd = 'curl -L -o "%s" %s' % (fname,url) - elif which('wget') != None: + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling curl failed with: %s" % e.output.decode('UTF-8')) + + if not success and 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 + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling wget failed with: %s" % e.output.decode('UTF-8')) + + if not success: + error("Failed to download source code with 'curl' or 'wget'") + return # parse args diff --git a/lib/smd/Install.py b/lib/smd/Install.py index 00891339d0806d319fbbacb2602eff12dba329b0..9247cb449b762b7435377d9fabef2eca4c7326d3 100644 --- a/lib/smd/Install.py +++ b/lib/smd/Install.py @@ -65,13 +65,27 @@ def which(program): return None def geturl(url,fname): + success = False + if which('curl') != None: cmd = 'curl -L -o "%s" %s' % (fname,url) - elif which('wget') != None: + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling curl failed with: %s" % e.output.decode('UTF-8')) + + if not success and 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 + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling wget failed with: %s" % e.output.decode('UTF-8')) + + if not success: + error("Failed to download source code with 'curl' or 'wget'") + return # parse args diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py index 4998358d27af55447ecf880d960d180d9fdc8fac..f40eb53bc67a0ff650bfe45635ba61879bd78231 100644 --- a/lib/voronoi/Install.py +++ b/lib/voronoi/Install.py @@ -64,13 +64,27 @@ def which(program): return None def geturl(url,fname): + success = False + if which('curl') != None: cmd = 'curl -L -o "%s" %s' % (fname,url) - elif which('wget') != None: + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling curl failed with: %s" % e.output.decode('UTF-8')) + + if not success and 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 + try: + subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + success = True + except subprocess.CalledProcessError as e: + print("Calling wget failed with: %s" % e.output.decode('UTF-8')) + + if not success: + error("Failed to download source code with 'curl' or 'wget'") + return # parse args