From b3e9505fab33af0e2420c98cea9b0b5dc9949677 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 19 Nov 2019 01:14:08 +0000 Subject: Cleaned up function calls a bit --- archinstall.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/archinstall.py b/archinstall.py index 83193aa7..2b3cc302 100644 --- a/archinstall.py +++ b/archinstall.py @@ -892,20 +892,22 @@ def mount_mountpoints(drive, bootpartition, mountpoint='/mnt/boot', *positionals return True def re_rank_mirrors(top=10, *positionals, **kwargs): - if sys_command(('/usr/bin/rankmirrors -n {top} /root/mirrorlist > /etc/pacman.d/mirrorlist')).exit_code == 0: + if sys_command(('/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist')).exit_code == 0: return True return False -def filter_mirrors_by_country(countries, top=10, *positionals, **kwargs): +def filter_mirrors_by_country_list(countries, top=None, *positionals, **kwargs): ## TODO: replace wget with urllib.request (no point in calling syscommand) country_list = [] for country in countries.split(','): country_list.append(f'country={country}') o = b''.join(sys_command((f"/usr/bin/wget 'https://www.archlinux.org/mirrorlist/?{'&'.join(country_list)}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' -O /root/mirrorlist"))) o = b''.join(sys_command(("/usr/bin/sed -i 's/#Server/Server/' /root/mirrorlist"))) + o = b''.join(sys_command(("/usr/bin/mv /root/mirrorlist /etc/pacman.d/"))) - if not re_rank_mirrors(top, *positionals, **kwargs) or not os.path.isfile('/etc/pacman.d/mirrorlist'): - o = b''.join(sys_command(("/usr/bin/mv /root/mirrorlist /etc/pacman.d/"))) + if top: + re_rank_mirrors(top, *positionals, **kwargs) or not os.path.isfile('/etc/pacman.d/mirrorlist') + return True def strap_in_base(*positionals, **kwargs): @@ -1167,7 +1169,7 @@ if __name__ == '__main__': if 'mirrors' in args and args['mirrors'] and 'country' in args and get_default_gateway_linux(): print('[N] Reordering mirrors.') - filter_mirrors_by_country(args['country']) + filter_mirrors_by_country_list([args['country']]) pre_conf = {} if 'pre' in instructions: -- cgit v1.2.3-70-g09d2