remove attempts to use urllib and use curl for all downloading. restore printing help with no flags.
This commit is contained in:
@ -1,44 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# install.py tool to setup the kim-api library
|
||||
# install.py tool to download, compile, and setup the kim-api library
|
||||
# used to automate the steps described in the README file in this dir
|
||||
|
||||
from __future__ import print_function
|
||||
import sys,os,re,subprocess
|
||||
|
||||
# transparently use either urllib or an external tool
|
||||
try:
|
||||
import ssl
|
||||
try: from urllib.request import urlretrieve as geturl
|
||||
except: from urllib import urlretrieve as geturl
|
||||
except:
|
||||
def geturl(url,fname):
|
||||
cmd = 'curl -L -o "%s" %s' % (fname,url)
|
||||
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
|
||||
return txt
|
||||
|
||||
help = """
|
||||
Syntax from src dir: make lib-kim args="-v version -a kim-name"
|
||||
Syntax from lib dir: python Install.py -v version -a kim-name
|
||||
Syntax from src dir: make lib-kim args="-b -v version -a kim-name"
|
||||
or: make lib-kim args="-b -a everything"
|
||||
or: make lib-kim args="-n -a kim-name"
|
||||
or: make lib-kim args="-p /usr/local/open-kim -a kim-name"
|
||||
Syntax from lib dir: python Install.py -b -v version -a kim-name
|
||||
or: python Install.py -b -a everything
|
||||
or: python Install.py -n -a kim-name
|
||||
or: python Install.py -p /usr/local/open-kim -a kim-name
|
||||
|
||||
specify one or more options, order does not matter
|
||||
|
||||
-v = version of KIM API library to use
|
||||
default = kim-api-v1.8.2 (current as of June 2017)
|
||||
-b = download and build base KIM API library with example Models (default)
|
||||
-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
|
||||
-n = do NOT download and build base KIM API library.
|
||||
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).
|
||||
If kim-name = everything, then rebuild KIM API library with
|
||||
all available OpenKIM Models (this implies -b).
|
||||
*all* available OpenKIM Models (make take a long time).
|
||||
-vv = be more verbose about what is happening while the script runs
|
||||
|
||||
Examples:
|
||||
|
||||
make lib-kim # install KIM API lib with only example models
|
||||
make lib-kim args="-b" # install KIM API lib with only example models
|
||||
make lib-kim args="-a Glue_Ercolessi_Adams_Al__MO_324507536345_001" # Ditto plus one model
|
||||
make lib-kim args="-a everything" # install KIM API lib with all models
|
||||
make lib-kim args="-b -a everything" # install KIM API lib with all models
|
||||
make lib-kim args="-n -a EAM_Dynamo_Ackland_W__MO_141627196590_002" # only add one model or model driver
|
||||
|
||||
See the list of KIM model drivers here:
|
||||
@ -52,8 +49,9 @@ https://openkim.org/kim-api
|
||||
in the "What is in the KIM API source package?" section
|
||||
"""
|
||||
|
||||
def error():
|
||||
print(help)
|
||||
def error(str=None):
|
||||
if not str: print(help)
|
||||
else: print("ERROR",str)
|
||||
sys.exit()
|
||||
|
||||
# expand to full path name
|
||||
@ -62,15 +60,21 @@ def error():
|
||||
def fullpath(path):
|
||||
return os.path.abspath(os.path.expanduser(path))
|
||||
|
||||
def geturl(url,fname):
|
||||
cmd = 'curl -L -o "%s" %s' % (fname,url)
|
||||
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
|
||||
return txt
|
||||
|
||||
# parse args
|
||||
|
||||
args = sys.argv[1:]
|
||||
nargs = len(args)
|
||||
if nargs == 0: error()
|
||||
|
||||
thisdir = os.environ['PWD']
|
||||
version = "kim-api-v1.8.2"
|
||||
|
||||
buildflag = True
|
||||
buildflag = False
|
||||
everythingflag = False
|
||||
addflag = False
|
||||
verboseflag = False
|
||||
|
||||
Reference in New Issue
Block a user