Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/hardware.py19
-rw-r--r--archinstall/lib/mirrors.py12
2 files changed, 16 insertions, 15 deletions
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index a8f87b80..bbfb06a9 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -1,4 +1,5 @@
import os
+from functools import partial
from pathlib import Path
from typing import Iterator, Optional, Union
@@ -75,12 +76,10 @@ def cpuinfo() -> Iterator[dict[str, str]]:
cpu[key.strip()] = value.strip()
-def meminfo(key: Optional[str] = None) -> Union[dict[str, int], int]:
+def meminfo(key: Optional[str] = None) -> Union[dict[str, int], Optional[int]]:
"""Returns a dict with memory info if called with no args
or the value of the given key of said dict.
"""
- mem_info = {}
-
with MEMINFO.open() as file:
mem_info = {
(columns := line.strip().split())[0].rstrip(':'): int(columns[1])
@@ -97,11 +96,11 @@ def has_wifi() -> bool:
return 'WIRELESS' in enrich_iface_types(list_interfaces().values()).values()
-def has_amd_cpu() -> bool:
- return any(cpu.get("vendor_id") == "AuthenticAMD" for cpu in cpuinfo())
+def has_cpu_vendor(vendor_id: str) -> bool:
+ return any(cpu.get("vendor_id") == vendor_id for cpu in cpuinfo())
-def has_intel_cpu() -> bool:
- return any(cpu.get("vendor_id") == "GenuineIntel" for cpu in cpuinfo())
+has_amd_cpu = partial(has_cpu_vendor, "AuthenticAMD")
+has_intel_cpu = partial(has_cpu_vendor, "GenuineIntel")
def has_uefi() -> bool:
return os.path.isdir('/sys/firmware/efi')
@@ -152,15 +151,15 @@ def product_name() -> Optional[str]:
return product.read().strip()
-def mem_available() -> Optional[str]:
+def mem_available() -> Optional[int]:
return meminfo('MemAvailable')
-def mem_free() -> Optional[str]:
+def mem_free() -> Optional[int]:
return meminfo('MemFree')
-def mem_total() -> Optional[str]:
+def mem_total() -> Optional[int]:
return meminfo('MemTotal')
diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py
index 2325282f..ed34b5d5 100644
--- a/archinstall/lib/mirrors.py
+++ b/archinstall/lib/mirrors.py
@@ -1,6 +1,6 @@
import urllib.error
import urllib.request
-from typing import Union
+from typing import Union, Mapping, Iterable
from .general import *
from .output import log
@@ -113,14 +113,16 @@ def insert_mirrors(mirrors, *args, **kwargs):
return True
-def use_mirrors(regions: dict, destination='/etc/pacman.d/mirrorlist'):
+def use_mirrors(
+ regions: Mapping[str, Iterable[str]],
+ destination: str ='/etc/pacman.d/mirrorlist'
+) -> None:
log(f'A new package mirror-list has been created: {destination}', level=logging.INFO)
- for region, mirrors in regions.items():
- with open(destination, 'w') as mirrorlist:
+ with open(destination, 'w') as mirrorlist:
+ for region, mirrors in regions.items():
for mirror in mirrors:
mirrorlist.write(f'## {region}\n')
mirrorlist.write(f'Server = {mirror}\n')
- return True
def re_rank_mirrors(