index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds@gmail.com> | 2021-11-01 11:57:04 +0000 |
---|---|---|
committer | Anton Hvornum <anton.feeds@gmail.com> | 2021-11-01 11:57:04 +0000 |
commit | b42b3a2ce5de7de22532f51d740197a8f2d9bb9c (patch) | |
tree | ffa52e75a5c0727c9152a03fac3f4e46f26f4280 /archinstall/lib/mirrors.py | |
parent | 566693c4f8a9b636c144cd43dd6f4030b670c9ce (diff) | |
parent | b8808491937a6140c9b4df00b4f27ef0405344a4 (diff) |
-rw-r--r-- | archinstall/lib/mirrors.py | 27 |
diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index 1b62a61b..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,20 +113,29 @@ 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(top=10, *positionals, **kwargs): - if SysCommand(f'/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist').exit_code == 0: - return True - return False +def re_rank_mirrors( + top: int = 10, + src: str = '/etc/pacman.d/mirrorlist', + dst: str = '/etc/pacman.d/mirrorlist', +) -> bool: + cmd = SysCommand(f"/usr/bin/rankmirrors -n {top} {src}") + if cmd.exit_code != 0: + return False + with open(dst, 'w') as f: + f.write(str(cmd)) + return True def list_mirrors(sort_order=["https", "http"]): |