Example #1
0
 def has_device_file_by_label(self) -> bool:
     """
     Check whether the device has a /dev/disk/by-label/xxx device path.
     :return: Returns `True` if a disk/by-label device path exists,
         otherwise `False`.
     :rtype: bool
     """
     return is_device_file_by_label(self.device_file_by_label)
Example #2
0
    def device_file_by_label(self) -> Optional[str]:
        """
        Get the device file, e.g.

        * /dev/disk/by-label/DATA
        * /dev/disk/by-label/My\x20Passport\x20Blue

        :return: Returns the escaped device file if available,
            otherwise `None`.
        :rtype: str | None
        """
        for device_link in self.device_links:
            if is_device_file_by_label(device_link):
                return device_link
        return None