Skip to content

Commit ca454c9

Browse files
committed
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
1 parent b9e2d2c commit ca454c9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib/component_information/generate_component_general.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import lzma #to create .xz file
66
import re
7+
import os
78

89
parser = argparse.ArgumentParser(description="""Generate the COMPONENT_GENERAL json file""")
910
parser.add_argument('filename', metavar='component_general.json', help='JSON output file')
@@ -75,5 +76,14 @@ def crc_update(buf, crc_table, crc):
7576
with open(filename, 'w') as outfile:
7677
json.dump(component_general, outfile)
7778

79+
# DEBUG: in some cases writing the compressed file fails with 'No such file or directory'
80+
# even though it was just written above
81+
if not os.path.isfile(filename):
82+
print('{:} does not exist'.format(filename))
83+
7884
if compress:
79-
save_compressed(filename)
85+
try:
86+
save_compressed(filename)
87+
except FileNotFoundError as e:
88+
print(os.listdir(os.path.dirname(filename)))
89+
raise

0 commit comments

Comments
 (0)