Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/hardware.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/hardware.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/hardware.py')
-rw-r--r--archinstall/lib/hardware.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 83323261..ea570707 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -6,6 +6,7 @@ from typing import Iterator, Optional, Union
from .general import SysCommand
from .networking import list_interfaces, enrich_iface_types
+from .exceptions import SysCallError
from .output import log
__packages__ = [
@@ -170,10 +171,19 @@ def mem_total() -> Optional[int]:
def virtualization() -> Optional[str]:
- return str(SysCommand("systemd-detect-virt")).strip('\r\n')
+ try:
+ return str(SysCommand("systemd-detect-virt")).strip('\r\n')
+ except SysCallError as error:
+ log(f"Could not detect virtual system: {error}", level=logging.DEBUG)
+
+ return None
def is_vm() -> bool:
- return b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower()
+ try:
+ return b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower()
+ except SysCallError as error:
+ log(f"System is not running in a VM: {error}", level=logging.DEBUG)
+ return None
# TODO: Add more identifiers