Skip to content
Snippets Groups Projects
Commit f181a0bf authored by Ryan S. Elliott's avatar Ryan S. Elliott
Browse files

Update lib/kim/Install.py for phthon 2.7 conversion

parent 81f342aa
No related branches found
No related tags found
No related merge requests found
...@@ -200,43 +200,52 @@ if addflag: ...@@ -200,43 +200,52 @@ if addflag:
print("Building item ...") print("Building item ...")
cmd = "cd %s/%s; make; make install" %(thisdir,addmodelname) cmd = "cd %s/%s; make; make install" %(thisdir,addmodelname)
subprocess.check_output(cmd,shell=True) try:
firstRunOutput = txt[1] txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if txt[0] != 0: except subprocess.CalledProcessError as e:
# Error: but first, check to see if it needs a driver # Error: but first, check to see if it needs a driver
firstRunOutput = e.output
cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname) cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname)
txt = subprocess.check_output(cmd,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if txt[1] == "ParameterizedModel": if txt == "ParameterizedModel":
# Get and install driver # Get and install driver
cmd = "cd %s/%s; make model-driver-name" % (thisdir,addmodelname) cmd = "cd %s/%s; make model-driver-name" % (thisdir,addmodelname)
txt = subprocess.check_output(cmd,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
adddrivername = txt[1] adddrivername = txt
print("First Installing model driver: %s" % adddrivername) print("First Installing model driver: %s" % adddrivername)
cmd = "cd %s; python Install.py -a %s" % (thisdir,adddrivername) cmd = "cd %s; python Install.py -a %s" % (thisdir,adddrivername)
txt = subprocess.check_output(cmd,shell=True) try:
if txt[0] != 0: txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
print(firstRunOutput) except subprocess.CalledProcessError as e:
print(txt[1]) print(e.output)
error() sys.exit()
else:
print(txt[1]) print(txt)
# now install the model that needed the driver
cmd = "cd %s; python Install.py -a %s" % (thisdir,addmodelname) cmd = "cd %s; python Install.py -a %s" % (thisdir,addmodelname)
txt = subprocess.check_output(cmd,shell=True) try:
print(txt[1]) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if txt[0] != 0: except subprocess.CalledProcessError as e:
error() print(e.output)
sys.exit()
print(txt)
sys.exit()
else: else:
print(firstRunOutput) print(firstRunOutput)
error() print("Error, unable to build and install OpenKIM item: %s" \
else: % addmodelname)
sys.exit()
# success
print(firstRunOutput) # success the first time
print("Removing kim item source and build files ...")
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" %(thisdir,addmodelname,addmodelname)
subprocess.check_output(cmd,shell=True)
print(txt)
print("Removing kim item source and build files ...")
cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" %(thisdir,addmodelname,addmodelname)
subprocess.check_output(cmd,shell=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment