mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 16:48:52 +08:00
component_information: add debug instrumentation for FileNotFoundError exception
The following exception occurs in some rare cases (but only with make build: NO_NINJA_BUILD=1 px4_sitl_default):
Traceback (most recent call last):
File "/__w/PX4-Autopilot/PX4-Autopilot/src/lib/component_information/generate_component_general.py", line 79, in <module>
save_compressed(filename)
File "/__w/PX4-Autopilot/PX4-Autopilot/src/lib/component_information/generate_component_general.py", line 33, in save_compressed
with open(filename, 'r') as content_file:
FileNotFoundError: [Errno 2] No such file or directory: '/__w/PX4-Autopilot/PX4-Autopilot/build/px4_sitl_default/component_general.json'
make[3]: *** [src/lib/component_information/CMakeFiles/component_information_header.dir/build.make:68: component_general.json] Error 1
This commit is contained in:
@@ -4,6 +4,7 @@ import argparse
|
||||
import json
|
||||
import lzma #to create .xz file
|
||||
import re
|
||||
import os
|
||||
|
||||
parser = argparse.ArgumentParser(description="""Generate the COMPONENT_GENERAL json file""")
|
||||
parser.add_argument('filename', metavar='component_general.json', help='JSON output file')
|
||||
@@ -75,5 +76,14 @@ component_general['metadataTypes'] = metadata_types
|
||||
with open(filename, 'w') as outfile:
|
||||
json.dump(component_general, outfile)
|
||||
|
||||
# DEBUG: in some cases writing the compressed file fails with 'No such file or directory'
|
||||
# even though it was just written above
|
||||
if not os.path.isfile(filename):
|
||||
print('{:} does not exist'.format(filename))
|
||||
|
||||
if compress:
|
||||
save_compressed(filename)
|
||||
try:
|
||||
save_compressed(filename)
|
||||
except FileNotFoundError as e:
|
||||
print(os.listdir(os.path.dirname(filename)))
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user