create directory before writing into the file.

The with open() method creates the file if it does not exist, but
gives a FileNotFound error if the path does not exist.

Hence, creating the path directories before using the file.

Bug: N/A
Test: the build passes.
Change-Id: Id5b285ea5581f7ef526876fb6e13a3bf69098acd
This commit is contained in:
Gurpreet Singh
2023-12-06 16:14:07 +00:00
parent 6d6755189d
commit 789b63dca0

View File

@@ -1307,6 +1307,7 @@ class SdkDistProducer:
def dist_generate_sdk_supported_modules_file(self, modules): def dist_generate_sdk_supported_modules_file(self, modules):
sdk_modules_file = os.path.join(self.dist_dir, "sdk-modules.txt") sdk_modules_file = os.path.join(self.dist_dir, "sdk-modules.txt")
os.makedirs(os.path.dirname(sdk_modules_file), exist_ok=True)
with open(sdk_modules_file, "w", encoding="utf8") as file: with open(sdk_modules_file, "w", encoding="utf8") as file:
for module in modules: for module in modules:
if module in MAINLINE_MODULES: if module in MAINLINE_MODULES: