From b2bcf5c3d9a712962f8a53388d3b7fe87e022455 Mon Sep 17 00:00:00 2001 From: Trecia Agoylo Date: Wed, 5 Jun 2024 12:20:20 +0800 Subject: [PATCH] update path handling Signed-off-by: Trecia Agoylo --- nebula/network.py | 3 ++- nebula/usbmux.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/nebula/network.py b/nebula/network.py index 779b9ff..ad2e2ef 100644 --- a/nebula/network.py +++ b/nebula/network.py @@ -294,7 +294,8 @@ def update_boot_partition_existing_files(self, subfolder=None): # extract needed boot files from the kuiper descriptor file h = helper() - descriptor_path = "nebula/resources/kuiper.json" + path = pathlib.Path(__file__).parent.absolute() + descriptor_path = os.path.join(path, "resources", "kuiper.json") try: self._dl_file("/tmp/sdcard/kuiper.json") os.replace("kuiper.json", descriptor_path) diff --git a/nebula/usbmux.py b/nebula/usbmux.py index 7560a6f..258c98b 100644 --- a/nebula/usbmux.py +++ b/nebula/usbmux.py @@ -2,6 +2,7 @@ import glob import logging import os +import pathlib import random import re import string @@ -287,6 +288,7 @@ def update_rootfs_files_from_external(self, target, destination): def update_boot_files_from_sdcard_itself( self, + descriptor_path=None, bootbin_loc=None, kernel_loc=None, devicetree_loc=None, @@ -297,6 +299,7 @@ def update_boot_files_from_sdcard_itself( """Update the boot files from the SD card itself. Args: + descriptor_path (str): The path to the kuiper.json. bootbin_loc (str): The path to the boot.bin file on the SD card. kernel_loc (str): The path to the kernel file on the SD card. devicetree_loc (str): The path to the devicetree file on the SD card. @@ -306,8 +309,8 @@ def update_boot_files_from_sdcard_itself( """ args = locals() # check if if all loc are still None - if "self" in args: - del args["self"] + del args["self"] + del args["descriptor_path"] args_status = all(loc is None for loc in args.values()) folder, boot_p = self._mount_sd_card() @@ -315,7 +318,11 @@ def update_boot_files_from_sdcard_itself( if args_status: h = helper() - descriptor_path = "nebula/resources/kuiper.json" + if descriptor_path: + descriptor_path=descriptor_path + else: + path = pathlib.Path(__file__).parent.absolute() + descriptor_path = os.path.join(path, "resources", "kuiper.json") try: kuiperjson_loc = os.path.join("/tmp/", folder, "kuiper.json") os.path.isfile(kuiperjson_loc)