Default to unknown on partition types (#2037)
Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
parent
2252dcf9bb
commit
c8e0b9a4d6
|
|
@ -20,6 +20,7 @@ from ..exceptions import DiskError, SysCallError
|
||||||
from ..general import SysCommand
|
from ..general import SysCommand
|
||||||
from ..output import debug, error
|
from ..output import debug, error
|
||||||
from ..storage import storage
|
from ..storage import storage
|
||||||
|
from ..output import info
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
_: Any
|
_: Any
|
||||||
|
|
@ -509,13 +510,15 @@ class BDevice:
|
||||||
class PartitionType(Enum):
|
class PartitionType(Enum):
|
||||||
Boot = 'boot'
|
Boot = 'boot'
|
||||||
Primary = 'primary'
|
Primary = 'primary'
|
||||||
|
_Unknown = 'unknown'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_type_from_code(cls, code: int) -> PartitionType:
|
def get_type_from_code(cls, code: int) -> PartitionType:
|
||||||
if code == parted.PARTITION_NORMAL:
|
if code == parted.PARTITION_NORMAL:
|
||||||
return PartitionType.Primary
|
return PartitionType.Primary
|
||||||
|
else:
|
||||||
raise DiskError(f'Partition code not supported: {code}')
|
info(f'Partition code not supported: {code}')
|
||||||
|
return PartitionType._Unknown
|
||||||
|
|
||||||
def get_partition_code(self) -> Optional[int]:
|
def get_partition_code(self) -> Optional[int]:
|
||||||
if self == PartitionType.Primary:
|
if self == PartitionType.Primary:
|
||||||
|
|
@ -659,9 +662,9 @@ class PartitionModification:
|
||||||
if partition_info.btrfs_subvol_infos:
|
if partition_info.btrfs_subvol_infos:
|
||||||
mountpoint = None
|
mountpoint = None
|
||||||
subvol_mods = []
|
subvol_mods = []
|
||||||
for info in partition_info.btrfs_subvol_infos:
|
for i in partition_info.btrfs_subvol_infos:
|
||||||
subvol_mods.append(
|
subvol_mods.append(
|
||||||
SubvolumeModification.from_existing_subvol_info(info)
|
SubvolumeModification.from_existing_subvol_info(i)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
mountpoint = partition_info.mountpoints[0] if partition_info.mountpoints else None
|
mountpoint = partition_info.mountpoints[0] if partition_info.mountpoints else None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue