Documentation for the Cygwin (Windows) module

This is the part of the package that contains the tools and information getters for Windows/Cygwin. This would normally be called from the getdevinfo module, but you can call it directly if you like.

Note

You can import this submodule directly, but it might result in strange behaviour, or not work on your platform if you import the wrong one. That is not how the package is intended to be used.

Warning

Feel free to experiment, but be aware that you may be able to cause crashes, exceptions, and generally weird situations by calling these methods directly if you get it wrong. A good place to look if you’re interested in this is the unit tests (in tests/).

Warning

This module won’t work properly unless it is executed as root.

getdevinfo.cygwin.compute_block_size(stdout)

Private, implementation detail.

Used to process and tidy up the block size output from smartctl.

Args:
stdout (str): The block size.
Returns:

int/None: The block size:

  • None - Failed!
  • int - The block size.

Usage:

>>> compute_block_size(<stdoutFromSmartctl>)
getdevinfo.cygwin.get_block_size(disk)

Public

This function uses the smartctl command to get the block size of the given device.

Args:
disk (str): The partition/device/logical volume that
we want the block size for.
Returns:

int/None. The block size.

  • None - Failed!
  • int - The block size.

Usage:

>>> block_size = get_block_size(<aDeviceName>)
getdevinfo.cygwin.get_boot_record(disk)

Private, implementation detail.

This function gets the MBR/PBR of a given disk.

Args:
disk (str): The name of a partition/device.
Returns:

tuple (string, string). The boot record (raw, any readable strings):

  • (“Unknown”, “Unknown”) - Couldn’t read it.
  • Anything else - The PBR/MBR and any readable strings therein.

Usage:

>>> boot_record, boot_record_strings = get_boot_record(<aDiskName>)
getdevinfo.cygwin.get_capabilities(disk)

Private, implementation detail.

This function gets the capabilities from the structure generated by parsing smartctl’s output.

Warning

Not yet implemented on Cygwin, returns empty list.

Args:
data (dict): Parsed JSON from smartctl.
Returns:

list. The capabilities:

  • [] - Couldn’t find them.
  • Anything else - The capabilities - as unicode strings.

Usage:

>>> capabilities = get_capabilities(<aNode>)
getdevinfo.cygwin.get_capacity(data)

Private, implementation detail.

This function gets the vendor from the structure generated by parsing smartctl’s output. Also rounds it to a human-readable form, and returns both pieces of data.

Args:
data: Parsed JSON from smartctl.
Returns:

tuple (string, string). The sizes (bytes, human-readable):

  • (“Unknown”, “Unknown”) - Couldn’t find them.
  • Anything else - The sizes.

Usage:

>>> raw_size, human_size = get_capacity(<smartctl-data>)
getdevinfo.cygwin.get_description(data, disk)

Private, implementation detail.

This function creates a description from the structure generated by parsing smartctl’s output.

Args:
data: Parsed JSON from smartctl. disk (str): Name of a device/partition.
Returns:
string. The description: This may contain various bits of info, or not,
depending on what macOS knows about the disk.

Usage:

>>> description = get_description(<smartctl-data>, <aDisk>)
getdevinfo.cygwin.get_device_info(host_disk)

Private, implementation detail.

This function gathers and assembles information for devices (whole disks). It employs some simple logic and the other functions defined in this module to do its work.

Note

Functionality not yet complete.

Args:
host_disk: The name of the device.
Returns:
string. The name of the device.

Usage:

>>> host_disk = get_device_info(<aNode>)
getdevinfo.cygwin.get_file_system(output)

Private, implementation detail.

This function gets the file system from blkid’s output.

Args:
output (list): Output from blkid.
Returns:

string. The file system:

  • “Unknown” - Couldn’t find it.
  • Anything else - The file system.

Usage:

>>> file_system = get_file_system(<blkid-output>)
getdevinfo.cygwin.get_id(disk)

Private, implementation detail.

This function gets the ID of a given partition or device.

Warning

Not yet implemented on Cygwin.

Args:
disk (str): The name of a partition/device.
Returns:

string. The ID:

  • “Unknown” - Couldn’t find it.
  • Anything else - The ID.

Usage:

>>> disk_id = get_id(<aDiskName>)
getdevinfo.cygwin.get_info()

This function is the Cygwin-specific way of getting disk information. It makes use of the smartctl and blkid commands to gather information.

It uses the other functions in this module to acheive its work, and it doesn’t return the disk infomation. Instead, it is left as a global attribute in this module (DISKINFO).

Raises:
Nothing, hopefully, but errors have a small chance of propagation up to here here. Wrap it in a try:, except: block if you are worried.

Usage:

>>> get_info()
getdevinfo.cygwin.get_partition_info(subnode, host_disk)

Private, implementation detail.

This function gathers and assembles information for partitions. It employs some simple logic and the other functions defined in this module to do its work.

Warning

Not yet implemented on Cygwin - returns None.

Args:
subnode: A “node” representing a partition, generated
from lshw’s XML output.
host_disk (str): The “parent” or “host” device. eg: for
/dev/sda1, the host disk would be /dev/sda. Used to organise everything nicely in the disk info dictionary.
Returns:
string. The name of the partition.

Usage:

>>> volume = get_device_info(<aNode>)
getdevinfo.cygwin.get_partitioning(output)

Private, implementation detail.

This function gets the partition scheme from blkid’s output.

Args:
output (list): Output from blkid.
Returns:

string (str). The partition scheme:

  • “Unknown” - Couldn’t find it.
  • “mbr” - Old-style MBR partitioning
    for BIOS systems.
  • “gpt” - New-style GPT partitioning.

Usage:

>>> partitioning = get_partitioning(<blkid-output>)
getdevinfo.cygwin.get_product(data)

Private, implementation detail.

This function gets the product from the structure generated by parsing smartctl’s output.

Args:
data: Parsed JSON from smartctl.
Returns:

string. The product:

  • “Unknown” - Couldn’t find it.
  • Anything else - The product.

Usage:

>>> product = get_product(<smartctl-data>)
getdevinfo.cygwin.get_uuid(output)

Private, implementation detail.

This function gets the UUID from blkid’s output.

Args:
output (list): Output from blkid.
Returns:

string. The UUID:

  • “Unknown” - Couldn’t find it.
  • Anything else - The UUID.

Usage:

>>> uuid = get_uuid(<blkid-output>)
getdevinfo.cygwin.get_vendor(data)

Private, implementation detail.

This function gets the vendor from the structure generated by parsing smartctl’s output.

Args:
data: Parsed JSON from smartctl.
Returns:

string. The vendor:

  • “Unknown” - Couldn’t find it.
  • Anything else - The vendor.

Usage:

>>> vendor = get_vendor(<smartctl-data>)