wd_fw_update package

Submodules

wd_fw_update.main module

class wd_fw_update.main.Drive(device: str = '', model: str = '', current_fw_version: str = '', slot_1_readonly: bool = None, slot_count: int = -1, current_slot: int = -1, slots_with_firmware: dict = <factory>, selected_slot: int = -1, activation_without_reset: bool = None, relative_fw_urls: ~typing.List[str] = <factory>, selected_version: str = '', firmware_url: str = '', activation_mode: int = -1, tmp_fw_file_name: str = '')[source]

Bases: object

Class for keeping track of the NVME drive and firmware properties.

activation_mode: int = -1
activation_without_reset: bool = None
current_fw_version: str = ''
current_slot: int = -1
device: str = ''
firmware_url: str = ''
model: str = ''
relative_fw_urls: List[str]
selected_slot: int = -1
selected_version: str = ''
slot_1_readonly: bool = None
slot_count: int = -1
slots_with_firmware: dict
tmp_fw_file_name: str = ''
wd_fw_update.main.ask_device(drive) None[source]

Prompt the user to select an NVME drive for the update.

Parameters:

drive (Drive) – The Drive object.

Returns:

None

Updates:

drive.device (str): The selected device path.

wd_fw_update.main.ask_fw_version(drive, manual_mode: bool) None[source]

Prompt the user to select a firmware version for the given drive.

Parameters:
  • drive (Drive) – The Drive object for which the firmware is being selected.

  • manual_mode (bool) – If True, include all available firmware versions in the selection. If False, only newer firmware versions than the current one are included.

Returns:

None

Updates:

drive.selected_version (str): Selected firmware version.

wd_fw_update.main.ask_mode(drive) None[source]

Prompt the user to select the firmware update mode

Parameters:

drive (Drive) – The Drive object.

Returns:

None

Updates:

drive.mode (int): Selected update mode.

wd_fw_update.main.ask_slot(drive) None[source]

Prompt the user to select a firmware slot

Parameters:

drive (Drive) – The Drive object.

Returns:

None

Updates:

drive.selected_slot (int): Selected slot number.

wd_fw_update.main.check_missing_dependencies() bool[source]

Check for missing dependencies

Returns:

True if any dependency is missing, False otherwise.

Return type:

is_missing (bool)

wd_fw_update.main.get_devices() List[str][source]

Returns a list of all NVME drives.

Returns:

List of NVME drives

Return type:

devices (List[str])

wd_fw_update.main.get_fw_url(drive: Drive) None[source]

Fetch firmware URL for the specified model from the device list.

Parameters:

drive (Drive) – The Drive object.

Returns:

None

Updates:

drive.relative_fw_urls (list): List of all fw properties urls.

wd_fw_update.main.get_model_properties(drive) None[source]

Retrieve model properties for the specified NVME device.

Parameters:

drive (Drive) – The Drive object.

Returns:

None

Updates:

drive.model (str): The selected device path. drive.current_fw_version (str): The current firmware version. drive.slot_1_readonly (bool): Is slot 1 readonly? drive.slot_count (int): How many slots are available. drive.activation_without_reset (bool): Does the drive support fw activation without reset? drive.current_slot (int): The currently active slot. drive.slots_with_firmware (dict): Dictionaly of slots that have a fw installed with its respective version.

wd_fw_update.main.get_upgrade_url(drive, manual_mode: bool) None[source]

Check if an upgrade from the current firmware to the new one is supported and returns the firmware url.

Parameters:
  • drive (Drive) – The Drive object.

  • manual_mode (bool) – If True, include all available firmware versions in the selection. If False, only firmware versions depending on the current one are included.

Returns:

None

Updates:

drive.firmware_url (str): URL to the firmware file.

wd_fw_update.main.main(args)[source]

Wrapper allowing wd_fw_update() to be called with string arguments in a CLI fashion

Instead of returning the value from wd_fw_update(), it prints the result to the stdout in a nicely formatted message.

Parameters:

args (List[str]) – command line parameters as list of strings (for example ["--verbose", "--help"]).

wd_fw_update.main.parse_args(args)[source]

Parse command line parameters

Parameters:

args (List[str]) – command line parameters as list of strings (for example ["--help"]).

Returns:

command line parameters namespace

Return type:

argparse.Namespace

wd_fw_update.main.print_info(drive=None) None[source]

Print an overview of the NVME drive.

wd_fw_update.main.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

This function is used as entry point to create console scripts with setuptools.

wd_fw_update.main.setup_logging(loglevel: int) None[source]

Setup basic logging

Parameters:

loglevel (int) – minimum loglevel for emitting messages

wd_fw_update.main.update_fw(drive) bool[source]

Update firmware for the specified NVME device

Parameters:
  • current_fw_version (str) – Current firmware version.

  • version (str) – Firmware version to be installed.

  • firmware_url (str) – URL to new firmware file.

  • model (str) – Model name.

  • device (str) – NVME device identifier.

  • current_slot (int) – Current active firmware slot.

  • slot (int) – Selected firmware slot.

  • mode (int) – Selected update mode.

Returns:

Success status.

Return type:

success (bool)

wd_fw_update.main.wd_fw_update(manual_mode)[source]

Updates the firmware of Western Digital SSDs on Ubuntu / Linux Mint. The user will be prompted for version / model / slot selection.

Module contents