Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions archinstall/lib/mirror/mirror_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def load_remote_mirrors(self) -> bool:

for attempt_nr in range(attempts):
try:
mirrorlist = fetch_data_from_url(url)
self._status_mappings = self._parse_remote_mirror_list(mirrorlist)
data = fetch_data_from_url(url)
self._status_mappings = self._parse_remote_mirror_list(data)
return True
except Exception as e:
debug(f'Error while fetching mirror list: {e}')
Expand Down Expand Up @@ -85,9 +85,9 @@ def get_status_by_region(self, region: str, speed_sort: bool) -> list[MirrorStat
# just return as-is without sorting?
return region_list

def _parse_remote_mirror_list(self, mirrorlist: str) -> dict[str, list[MirrorStatusEntryV3]]:
def _parse_remote_mirror_list(self, data: bytes) -> dict[str, list[MirrorStatusEntryV3]]:
context = {'verbose': self.verbose}
mirror_status = MirrorStatusListV3.model_validate_json(mirrorlist, context=context)
mirror_status = MirrorStatusListV3.model_validate_json(data, context=context)

sorting_placeholder: dict[str, list[MirrorStatusEntryV3]] = {}

Expand Down
5 changes: 2 additions & 3 deletions archinstall/lib/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def enrich_iface_types(interfaces: list[str]) -> dict[str, str]:
return result


def fetch_data_from_url(url: str, params: dict[str, str] | None = None, timeout: int = 30) -> str:
def fetch_data_from_url(url: str, params: dict[str, str] | None = None, timeout: int = 30) -> bytes:
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
Expand All @@ -134,8 +134,7 @@ def fetch_data_from_url(url: str, params: dict[str, str] | None = None, timeout:

try:
response = urlopen(full_url, context=ssl_context, timeout=timeout)
data = response.read().decode('UTF-8')
return data
return response.read()
except URLError as e:
raise ValueError(f'Unable to fetch data from url: {url}\n{e}')
except Exception as e:
Expand Down
4 changes: 1 addition & 3 deletions archinstall/lib/profile/profiles_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,8 @@ def _import_profile_from_url(self, url: str) -> None:
err = tr('Unable to fetch profile from specified url: {}').format(url)
error(err)
else:
b_data = bytes(data, 'utf-8')

with NamedTemporaryFile(delete=False, suffix='.py') as fp:
fp.write(b_data)
fp.write(data)
filepath = Path(fp.name)

profiles = self._process_profile_file(filepath)
Expand Down