Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/blockdevice.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-02-02 08:18:12 +0100
committerGitHub <noreply@github.com>2022-02-02 08:18:12 +0100
commit7f01747efcb15375b8e8601edafa2d9b89e38061 (patch)
treec65ae1a97d2db5b9029c337a11c1a2e79bc21911 /archinstall/lib/disk/blockdevice.py
parenta7c57bac53dd807091d34f5a3c23d89a87185c62 (diff)
Torxed fix sys command calls (#932)
* Fixed exceptions in is_vm() and virtualization() * Added exception handling for parted in BlockDevice.free_space
Diffstat (limited to 'archinstall/lib/disk/blockdevice.py')
-rw-r--r--archinstall/lib/disk/blockdevice.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py
index 5ffa06a8..fac258ef 100644
--- a/archinstall/lib/disk/blockdevice.py
+++ b/archinstall/lib/disk/blockdevice.py
@@ -8,7 +8,7 @@ from typing import Optional, Dict, Any, Iterator, Tuple, List, TYPE_CHECKING
if TYPE_CHECKING:
from .partition import Partition
-from ..exceptions import DiskError
+from ..exceptions import DiskError, SysCallError
from ..output import log
from ..general import SysCommand
from ..storage import storage
@@ -189,10 +189,13 @@ class BlockDevice:
# that is "outside" the disk. in /dev/sr0 this is usually the case with Archiso,
# so the free will ignore the ESP partition and just give the "free" space.
# Doesn't harm us, but worth noting in case something weird happens.
- for line in SysCommand(f"parted -s --machine {self.path} print free"):
- if 'free' in (free_space := line.decode('UTF-8')):
- _, start, end, size, *_ = free_space.strip('\r\n;').split(':')
- yield (start, end, size)
+ try:
+ for line in SysCommand(f"parted -s --machine {self.path} print free"):
+ if 'free' in (free_space := line.decode('UTF-8')):
+ _, start, end, size, *_ = free_space.strip('\r\n;').split(':')
+ yield (start, end, size)
+ except SysCallError as error:
+ log(f"Could not get free space on {self.path}: {error}", level=logging.INFO)
@property
def largest_free_space(self) -> List[str]: