Tools: allow to use sim_vehicle.py without pymavlink installed

This commit is contained in:
Pierre Kancir 2021-09-03 17:03:29 +02:00 committed by Andrew Tridgell
parent 13b0e3091d
commit 575c608688

View File

@ -28,7 +28,6 @@ import shlex
import binascii
import math
from pymavlink import mavextra
from pysim import vehicleinfo
@ -38,6 +37,12 @@ windowID = []
autotest_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.realpath(os.path.join(autotest_dir, '../..'))
try:
from pymavlink import mavextra
except ImportError:
sys.path.append(os.path.join(root_dir, "modules/mavlink"))
from pymavlink import mavextra
os.environ["SIM_VEHICLE_SESSION"] = binascii.hexlify(os.urandom(8)).decode()