microRTPS bridge: try/catch FastRTPSGen errors

This commit is contained in:
TSC21
2019-10-02 12:32:25 +01:00
committed by Nuno Marques
parent 2677e12024
commit 5c0f01a8b8
+12 -11
View File
@@ -245,12 +245,13 @@ if fastrtpsgen_include is not None and fastrtpsgen_include != '':
# follow the Fast-RTPS version convention # follow the Fast-RTPS version convention
fastrtpsgen_version = 0.0 fastrtpsgen_version = 0.0
if(os.path.exists(fastrtpsgen_path)): if(os.path.exists(fastrtpsgen_path)):
fastrtpsgen_version_out = subprocess.check_output( try:
[fastrtpsgen_path, "-version"]).strip()[-5:-2] fastrtpsgen_version_out = subprocess.check_output(
if not fastrtpsgen_version_out: [fastrtpsgen_path, "-version"]).strip()[-5:-2]
raise Exception( except OSError:
"FastRTPSGen failed with code error %s" % fastrtpsgen_version) raise
else:
if fastrtpsgen_version_out:
fastrtpsgen_version = float(fastrtpsgen_version_out) fastrtpsgen_version = float(fastrtpsgen_version_out)
else: else:
raise Exception( raise Exception(
@@ -412,11 +413,11 @@ def generate_agent(out_dir):
if not glob.glob(os.path.join(idl_dir, "*.idl")): if not glob.glob(os.path.join(idl_dir, "*.idl")):
raise Exception("No IDL files found in %s" % idl_dir) raise Exception("No IDL files found in %s" % idl_dir)
for idl_file in glob.glob(os.path.join(idl_dir, "*.idl")): for idl_file in glob.glob(os.path.join(idl_dir, "*.idl")):
ret = subprocess.call(fastrtpsgen_path + " -d " + out_dir + try:
"/fastrtpsgen -example x64Linux2.6gcc " + fastrtpsgen_include + idl_file, shell=True) ret = subprocess.check_call(fastrtpsgen_path + " -d " + out_dir +
if ret: "/fastrtpsgen -example x64Linux2.6gcc " + fastrtpsgen_include + idl_file, shell=True)
raise Exception( except OSError:
"FastRTPSGen failed with code error %s" % ret) raise
rm_wildcard(os.path.join(out_dir, "fastrtpsgen/*PubSubMain*")) rm_wildcard(os.path.join(out_dir, "fastrtpsgen/*PubSubMain*"))
rm_wildcard(os.path.join(out_dir, "fastrtpsgen/makefile*")) rm_wildcard(os.path.join(out_dir, "fastrtpsgen/makefile*"))