sim_vehicle.py: wrap jsbsim version fetch in a try

This commit is contained in:
Peter Barker 2016-05-16 11:58:53 +10:00
parent 39fc17f384
commit 38010cf3f3
1 changed files with 6 additions and 1 deletions

View File

@ -123,7 +123,12 @@ def check_jsbsim_version():
'''assert that the JSBSim we will run is the one we expect to run'''
jsbsim_cmd = ["JSBSim", "--version"]
progress_cmd("Get JSBSim version", jsbsim_cmd)
jsbsim_version = subprocess.Popen(jsbsim_cmd, stdout=subprocess.PIPE).communicate()[0]
try:
jsbsim_version = subprocess.Popen(jsbsim_cmd, stdout=subprocess.PIPE).communicate()[0]
except OSError as e:
jsbsim_version = '' # this value will trigger the ".index"
# check below and produce a reasonable
# error message
try:
jsbsim_version.index("ArduPilot")
except ValueError: