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
7 changes: 4 additions & 3 deletions archinstall/lib/boot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
from collections.abc import Iterator
from types import TracebackType

from .exceptions import SysCallError
from .general import SysCommand, SysCommandWorker, locate_binary
Expand Down Expand Up @@ -47,13 +48,13 @@ def __enter__(self) -> 'Boot':
storage['active_boot'] = self
return self

def __exit__(self, *args: str, **kwargs: str) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
# b''.join(sys_command('sync')) # No need to, since the underlying fs() object will call sync.
# TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager

if len(args) >= 2 and args[1]:
if exc_type is not None:
error(
args[1],
str(exc_value),
f'The error above occurred in a temporary boot-up of the installation {self.instance}',
)

Expand Down
13 changes: 7 additions & 6 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pathlib import Path
from select import EPOLLHUP, EPOLLIN, epoll
from shutil import which
from types import TracebackType
from typing import Any, override

from .exceptions import RequirementError, SysCallError
Expand Down Expand Up @@ -170,7 +171,7 @@ def __str__(self) -> str:
def __enter__(self) -> 'SysCommandWorker':
return self

def __exit__(self, *args: str) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
# b''.join(sys_command('sync')) # No need to, since the underlying fs() object will call sync.
# TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager

Expand All @@ -186,8 +187,8 @@ def __exit__(self, *args: str) -> None:
sys.stdout.write('\n')
sys.stdout.flush()

if len(args) >= 2 and args[1]:
debug(args[1])
if exc_type is not None:
debug(str(exc_value))

if self.exit_code != 0:
raise SysCallError(
Expand Down Expand Up @@ -327,12 +328,12 @@ def __init__(
def __enter__(self) -> SysCommandWorker | None:
return self.session

def __exit__(self, *args: str, **kwargs: dict[str, Any]) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
# b''.join(sys_command('sync')) # No need to, since the underlying fs() object will call sync.
# TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager

if len(args) >= 2 and args[1]:
error(args[1])
if exc_type is not None:
error(str(exc_value))

def __iter__(self, *args: list[Any], **kwargs: dict[str, Any]) -> Iterator[bytes]:
if self.session:
Expand Down
8 changes: 5 additions & 3 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,19 @@ def __init__(
def __enter__(self) -> 'Installer':
return self

def __exit__(self, exc_type: type[BaseException] | None, exc_val, exc_tb: TracebackType | None) -> bool:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None:
if exc_type is not None:
error(exc_val)
error(str(exc_value))

self.sync_log_to_install_medium()

# We avoid printing /mnt/<log path> because that might confuse people if they note it down
# and then reboot, and a identical log file will be found in the ISO medium anyway.
Tui.print(str(tr('[!] A log file has been created here: {}').format(logger.path)))
Tui.print(tr('Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues'))
raise exc_val

# Return None to propagate the exception
return None

if not (missing_steps := self.post_install_check()):
msg = f'Installation completed without any errors.\nLog files temporarily available at {logger.directory}.\nYou may reboot when ready.\n'
Expand Down
3 changes: 2 additions & 1 deletion archinstall/lib/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dataclasses import dataclass
from pathlib import Path
from subprocess import CalledProcessError
from types import TracebackType

from archinstall.lib.disk.utils import get_lsblk_info, umount

Expand Down Expand Up @@ -47,7 +48,7 @@ def __post_init__(self) -> None:
def __enter__(self) -> None:
self.unlock(self.key_file)

def __exit__(self, *args: str, **kwargs: str) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
if self.auto_unmount:
self.lock()

Expand Down
11 changes: 7 additions & 4 deletions archinstall/lib/menu/abstract_menu.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from types import TracebackType
from typing import Any, Self

from archinstall.lib.translationhandler import tr
Expand Down Expand Up @@ -36,13 +37,15 @@ def __enter__(self, *args: Any, **kwargs: Any) -> Self:
self.is_context_mgr = True
return self

def __exit__(self, *args: Any, **kwargs: Any) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
# TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager
# TODO: skip processing when it comes from a planified exit
if len(args) >= 2 and args[1]:
error(args[1])
if exc_type is not None:
error(str(exc_value))
Tui.print('Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues')
raise args[1]

# Return None to propagate the exception
return None

self.sync_all_to_config()

Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __enter__(self) -> Self:
self.start_time = time.time()
return self

def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
if self.start_time:
time_delta = time.time() - self.start_time
signal.alarm(0)
Expand Down
2 changes: 1 addition & 1 deletion archinstall/tui/curses_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ def __enter__(self) -> None:
tui = self.init()
Tui._t = tui

def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, tb: TracebackType | None) -> None:
def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
self.stop()

@property
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ ignore = [
"PLW1514", # unspecified-encoding
"PLW1641", # eq-without-hash
"PLW2901", # redefined-loop-name
"PYI036", # bad-exit-annotation
"RUF005", # collection-literal-concatenation
"RUF015", # unnecessary-iterable-allocation-for-first-element
"RUF039", # unraw-re-pattern
Expand Down