Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: kimpaller <[email protected]>
  • Loading branch information
kimpaller committed Feb 16, 2024
1 parent 8db61cf commit c5957dd
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 217 deletions.
39 changes: 23 additions & 16 deletions nebula/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def recover_board( # noqa:C901
devicetree_loc=devtreepath,
extlinux_loc=extlinux_path,
scr_loc=scr_path,
preloader_loc=preloader_path
preloader_loc=preloader_path,
)
# if devtreepath:
# self.usbsdmux.update_devicetree_for_mux(devtreepath)
Expand Down Expand Up @@ -424,7 +424,7 @@ def board_reboot_uart_net_pdu(
devtreepath,
extlinux_path=None,
scr_path=None,
preloader_path=None
preloader_path=None,
):
"""Manager when UART, PDU, and Network are available"""
self._check_files_exist(
Expand All @@ -434,7 +434,7 @@ def board_reboot_uart_net_pdu(
devtreepath,
extlinux_path,
scr_path,
preloader_path
preloader_path,
)
try:
# Flush UART
Expand Down Expand Up @@ -546,7 +546,7 @@ def board_reboot_sdmux_pdu(
preloader_path=None,
):
"""Manager when sdcardmux, pdu is available"""

try:
# Flush UART
self.monitor[0]._read_until_stop() # Flush
Expand Down Expand Up @@ -730,17 +730,17 @@ def _find_boot_files(self, folder):

targets = {
"bit": ["system_top.bit"],
"bootbin": ["BOOT.BIN","soc_system.rbf"],
"kernel": ["uImage","Image","zImage"],
"dt": ["devicetree.dtb","system.dtb","socfpga.dtb"],
"bootbin": ["BOOT.BIN", "soc_system.rbf"],
"kernel": ["uImage", "Image", "zImage"],
"dt": ["devicetree.dtb", "system.dtb", "socfpga.dtb"],
"ext": ["extlinux.conf"],
"scr": ["u-boot.scr"],
"preloader" : ["u-boot-with-spl.sfp"],
"preloader": ["u-boot-with-spl.sfp"],
"uboot": [
"u-boot_zynq.elf",
"u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf",
"u-boot_xilinx_zynqmp_zcu102_revA.elf"
]
"u-boot_xilinx_zynqmp_zcu102_revA.elf",
],
}
required = ["bootbin", "dt", "kernel"]
found_files = {}
Expand All @@ -749,7 +749,7 @@ def _find_boot_files(self, folder):
if pattern in files:
found_files.update({filetype: os.path.join(folder, pattern)})
continue
if not filetype in found_files.keys():
if filetype not in found_files.keys():
if filetype in required:
raise Exception(f"{filetype} - {pattern} not found")
else:
Expand All @@ -766,7 +766,6 @@ def _find_boot_files(self, folder):
found_files["uboot"],
)


def board_reboot_auto_folder(
self, folder, sdcard=False, design_name=None, recover=False, jtag_mode=False
):
Expand Down Expand Up @@ -795,8 +794,16 @@ def board_reboot_auto_folder(

else:
log.info("SD-Card/microblaze based device selected")
(bit, bootbin, kernel, dt, ext, scr, preloader, uboot) = \
self._find_boot_files(folder)
(
bit,
bootbin,
kernel,
dt,
ext,
scr,
preloader,
uboot,
) = self._find_boot_files(folder)

if jtag_mode:
self.board_reboot_jtag_uart(
Expand Down Expand Up @@ -851,7 +858,7 @@ def board_reboot_auto(
devtreepath=devtreepath,
extlinux_path=extlinux_path,
scr_path=scr_path,
preloader_path=preloader_path
preloader_path=preloader_path,
)
else:
self.board_reboot_uart_net_pdu(
Expand All @@ -861,7 +868,7 @@ def board_reboot_auto(
devtreepath=devtreepath,
extlinux_path=extlinux_path,
scr_path=scr_path,
preloader_path=preloader_path
preloader_path=preloader_path,
)

def shutdown_powerdown_board(self):
Expand Down
4 changes: 3 additions & 1 deletion nebula/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def update_boot_partition(
if preloader_path:
preloader_file = os.path.basename(preloader_path)
self.copy_file_to_remote(preloader_path, "/tmp/sdcard/")
self.run_ssh_command(f"dd if=/tmp/sdcard/{preloader_file} of=/dev/mmcblk0p3 bs=512 && sync")
self.run_ssh_command(
f"dd if=/tmp/sdcard/{preloader_file} of=/dev/mmcblk0p3 bs=512 && sync"
)
self.run_ssh_command("sudo reboot", ignore_exceptions=True)

def update_boot_partition_existing_files(self, subfolder=None):
Expand Down
20 changes: 11 additions & 9 deletions nebula/usbmux.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def update_boot_files_from_external(
devicetree_loc (str): The path to the devicetree file
devicetree_overlay_loc (str): The path to the devicetree overlay file
devicetree_overlay_config (str): The devicetree overlay configuration to be written on /boot/config.txt
extlinux_loc (str): The path to the Extlinux configuratoin file (Intel boards).
extlinux_loc (str): The path to the Extlinux configuration file (Intel boards).
scr_loc (str): The path to the .scr file (Intel boards).
preloader_loc (str): The path to the preloader file (.sfp) (Intel boards).
"""
Expand All @@ -230,15 +230,15 @@ def update_boot_files_from_external(
continue
bootfile_name = os.path.basename(bootfile_loc)
if not os.path.isfile(bootfile_loc):
raise Exception("File not found: " + loc)
raise Exception("File not found: " + bootfile_loc)

if field == "devicetree_overlay_loc":
outfile = os.path.join(
"/tmp", folder, "overlays", bootfile_name
)
outfile = os.path.join("/tmp", folder, "overlays", bootfile_name)
elif field == "preloader_loc":
log.info(f"Writing {bootfile_loc} to /dev/{preloader_p} ")
os.system(f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress')
os.system(
f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress'
)
continue
elif field == "extlinux_loc":
os.system(f"mkdir -p /tmp/{folder}/extlinux")
Expand Down Expand Up @@ -297,7 +297,7 @@ def update_boot_files_from_sdcard_itself(
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.
extlinux_loc (str): The path to the Extlinux configuratoin file on the SD card (Intel boards).
extlinux_loc (str): The path to the Extlinux configuration file on the SD card (Intel boards).
scr_loc (str): The path to the .scr file on the SD card (Intel boards).
preloader_loc (str): The path to the preloader file (.sfp) on the SD card (Intel boards).
"""
Expand All @@ -307,7 +307,7 @@ def update_boot_files_from_sdcard_itself(
preloader_p = f"{self._target_sdcard}3"

try:
for field,bootfile_loc in args.items():
for field, bootfile_loc in args.items():
if field in ["self"]:
continue
bootfile_loc = os.path.join("/tmp/", folder, bootfile_loc)
Expand All @@ -325,7 +325,9 @@ def update_boot_files_from_sdcard_itself(
+ "\n".join(options)
)
if field == "preloader_loc":
os.system(f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress')
os.system(
f'dd if={bootfile_loc} of="/dev/{preloader_p}" bs=512 status=progress'
)
continue

bootfile_name = os.path.basename(bootfile_loc)
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from nebula import pdu
from nebula import usbmux
from nebula import pdu, usbmux


def pytest_addoption(parser):
Expand Down Expand Up @@ -45,6 +44,7 @@ def power_on_dut(param):
p.power_up_board()
yield


@pytest.fixture()
def sdmux_dutmode(param):
u = usbmux(
Expand All @@ -54,6 +54,7 @@ def sdmux_dutmode(param):
u.set_mux_mode(mode="dut")
yield


@pytest.fixture()
def sdmux_hostmode(param):
u = usbmux(
Expand All @@ -63,6 +64,7 @@ def sdmux_hostmode(param):
u.set_mux_mode(mode="host")
yield


@pytest.fixture()
def sdmux_offmode(param):
u = usbmux(
Expand Down
2 changes: 1 addition & 1 deletion tests/nebula_config/nebula-manager-usbmux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ socfpga_cyclone5_de10_nano_cn0540:
- logfilename: socfpga_cyclone5_de10_nano_cn0540.log
- uboot_done_string: =>
usbmux-config:
- target_mux: id-000000001396
- target_mux: id-000000001396
17 changes: 11 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ def test_show_log():

@pytest.mark.hardware
@pytest.mark.parametrize(
"config",[
("eval-cn0508-rpiz", os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml")),
]
"config",
[
(
"eval-cn0508-rpiz",
os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"),
),
],
)
def test_usbmux_backup_update_bootfiles(power_off_dut, config):
test_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -138,13 +142,14 @@ def test_usbmux_backup_update_bootfiles(power_off_dut, config):

@pytest.mark.hardware
@pytest.mark.parametrize(
"config",[
"config",
[
(
"eval-cn0508-rpiz",
os.path.join(os.path.dirname(__file__), "nebula_config", "nebula-rpi.yaml"),
"5.15.92-v7+"
"5.15.92-v7+",
),
]
],
)
def test_usbmux_backup_update_modules(power_off_dut, config):
test_dir = os.path.dirname(__file__)
Expand Down
Loading

0 comments on commit c5957dd

Please sign in to comment.