From 463114356cd195b5402fc7f280508fea6566a7df Mon Sep 17 00:00:00 2001 From: Abhay Mohandas <80393938+abhay-mohandas@users.noreply.github.com> Date: Mon, 1 Aug 2022 19:09:39 +0530 Subject: Option for Parallel Downloads (#1397) * Adding menu * Working on parallel downloads * error updates * updates * update * Few more updates * bug fixes * More bug fixes * Minor bug fixes * Few changes * Minor changes * Cleaned up add_number_of_parrallel_downloads() and hid it behind --advanced * Forgot one import * Fixed flake8 Co-authored-by: Anton Hvornum --- archinstall/lib/user_interaction/__init__.py | 2 +- archinstall/lib/user_interaction/general_conf.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/user_interaction') diff --git a/archinstall/lib/user_interaction/__init__.py b/archinstall/lib/user_interaction/__init__.py index 8aba4b4d..a1ca2652 100644 --- a/archinstall/lib/user_interaction/__init__.py +++ b/archinstall/lib/user_interaction/__init__.py @@ -7,6 +7,6 @@ from .network_conf import ask_to_configure_network from .partitioning_conf import select_partition, select_encrypted_partitions from .general_conf import (ask_ntp, ask_for_a_timezone, ask_for_audio_selection, select_language, select_mirror_regions, select_profile, select_archinstall_language, ask_additional_packages_to_install, - select_additional_repositories, ask_hostname) + select_additional_repositories, ask_hostname, add_number_of_parrallel_downloads) from .disk_conf import ask_for_main_filesystem_format, select_individual_blockdevice_usage, select_disk_layout, select_disk from .utils import get_password, do_countdown diff --git a/archinstall/lib/user_interaction/general_conf.py b/archinstall/lib/user_interaction/general_conf.py index 754ffa29..44147afa 100644 --- a/archinstall/lib/user_interaction/general_conf.py +++ b/archinstall/lib/user_interaction/general_conf.py @@ -1,6 +1,7 @@ from __future__ import annotations import logging +import pathlib from typing import List, Any, Optional, Dict, TYPE_CHECKING from ..menu.menu import MenuSelectionType @@ -205,6 +206,29 @@ def ask_additional_packages_to_install(pre_set_packages: List[str] = []) -> List return packages +def add_number_of_parrallel_downloads(input_number :Optional[int] = None) -> Optional[int]: + print(_("Enter the number of parallel downloads to be enabled.\n [Default value is 0]")) + + while input_number is None: + try: + input_number = int(TextInput("> ").run().strip() or 0) + break + except: + print(_("Invalid input! Try again with a valid input")) + + pacman_conf_path = pathlib.Path("/etc/pacman.conf") + with pacman_conf_path.open() as f: + pacman_conf = f.read().split("\n") + + with pacman_conf_path.open("w") as fwrite: + for line in pacman_conf: + if "ParallelDownloads" in line: + fwrite.write(f"ParallelDownloads = {input_number}\n") + else: + fwrite.write(f"{line}\n") + + return input_number + def select_additional_repositories(preset: List[str]) -> List[str]: """ -- cgit v1.2.3-70-g09d2