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
4 changes: 2 additions & 2 deletions archinstall/lib/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def is_alive(self) -> bool:

return self.session.is_alive()

def SysCommand(self, cmd: list[str], *args: Any, **kwargs: Any) -> SysCommand:
def sys_command(self, cmd: list[str], *args: Any, **kwargs: Any) -> SysCommand:
return SysCommand(['systemd-run', f'--machine={self.container_name}', '--pty', *cmd], *args, **kwargs)

def SysCommandWorker(self, cmd: list[str], *args: Any, **kwargs: Any) -> SysCommandWorker:
def sys_command_worker(self, cmd: list[str], *args: Any, **kwargs: Any) -> SysCommandWorker:
return SysCommandWorker(['systemd-run', f'--machine={self.container_name}', '--pty', *cmd], *args, **kwargs)
6 changes: 3 additions & 3 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
udev_sync,
umount,
)
from archinstall.lib.exceptions import DiskError, SysCallError, UnknownFilesystemFormat
from archinstall.lib.exceptions import DiskError, SysCallError, UnknownFilesystemFormatError
from archinstall.lib.hardware import SysInfo
from archinstall.lib.log import debug, error, info, log
from archinstall.lib.models.device import (
Expand Down Expand Up @@ -259,7 +259,7 @@ def format(
case FilesystemType.LINUX_SWAP:
command = 'mkswap'
case _:
raise UnknownFilesystemFormat(f'Filetype "{fs_type.value}" is not supported')
raise UnknownFilesystemFormatError(f'Filetype "{fs_type.value}" is not supported')

if not command:
command = f'mkfs.{mkfs_type}'
Expand Down Expand Up @@ -629,7 +629,7 @@ def wipe_dev(self, block_device: BDevice) -> None:

for partition in block_device.partition_infos:
luks = Luks2(partition.path)
if luks.isLuks():
if luks.is_luks():
luks.erase()

self._wipe(partition.path)
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/disk/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def mapper_dev(self) -> Path | None:
return Path(f'/dev/mapper/{self.mapper_name}')
return None

def isLuks(self) -> bool:
def is_luks(self) -> bool:
try:
SysCommand(f'cryptsetup isLuks {self.luks_dev_path}')
return True
Expand Down
8 changes: 4 additions & 4 deletions archinstall/lib/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DiskError(Exception):
pass


class UnknownFilesystemFormat(Exception):
class UnknownFilesystemFormatError(Exception):
pass


Expand All @@ -22,19 +22,19 @@ class HardwareIncompatibilityError(Exception):
pass


class ServiceException(Exception):
class ServiceExceptionError(Exception):
pass


class PackageError(Exception):
pass


class Deprecated(Exception):
class DeprecatedError(Exception):
pass


class DownloadTimeout(Exception):
class DownloadTimeoutError(Exception):
"""
Download timeout exception raised by DownloadTimer.
"""
4 changes: 2 additions & 2 deletions archinstall/lib/general/general_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ async def select_language(preset: str | None = None) -> str | None:
from archinstall.lib.locale.locale_menu import select_kb_layout

# We'll raise an exception in an upcoming version.
# from ..exceptions import Deprecated
# raise Deprecated("select_language() has been deprecated, use select_kb_layout() instead.")
# from ..exceptions import DeprecatedError
# raise DeprecatedError("select_language() has been deprecated, use select_kb_layout() instead.")

# No need to translate this i feel, as it's a short lived message.
warn('select_language() is deprecated, use select_kb_layout() instead. select_language() will be removed in a future version')
Expand Down
22 changes: 14 additions & 8 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
mount,
swapon,
)
from archinstall.lib.exceptions import DiskError, HardwareIncompatibilityError, RequirementError, ServiceException, SysCallError
from archinstall.lib.exceptions import (
DiskError,
HardwareIncompatibilityError,
RequirementError,
ServiceExceptionError,
SysCallError,
)
from archinstall.lib.hardware import SysInfo
from archinstall.lib.linux_path import LPath
from archinstall.lib.locale.utils import verify_keyboard_layout, verify_x11_keyboard_layout
Expand Down Expand Up @@ -713,7 +719,7 @@ def enable_service(self, services: str | list[str]) -> None:
try:
SysCommand(f'systemctl --root={self.target} enable {service}')
except SysCallError as err:
raise ServiceException(f'Unable to start service {service}: {err}')
raise ServiceExceptionError(f'Unable to start service {service}: {err}')

for plugin in plugins.values():
if hasattr(plugin, 'on_service'):
Expand All @@ -729,7 +735,7 @@ def disable_service(self, services_disable: str | list[str]) -> None:
try:
SysCommand(f'systemctl --root={self.target} disable {service}')
except SysCallError as err:
raise ServiceException(f'Unable to disable service {service}: {err}')
raise ServiceExceptionError(f'Unable to disable service {service}: {err}')

def run_command(self, cmd: str, peek_output: bool = False) -> SysCommand:
return SysCommand(f'arch-chroot -S {self.target} {cmd}', peek_output=peek_output)
Expand Down Expand Up @@ -2051,9 +2057,9 @@ def set_keyboard_language(self, language: str) -> bool:
os.system('systemd-run --machine=archinstall --pty localectl set-keymap ""') # type: ignore[deprecated]

try:
session.SysCommand(['localectl', 'set-keymap', language])
session.sys_command(['localectl', 'set-keymap', language])
except SysCallError as err:
raise ServiceException(f"Unable to set locale '{language}' for console: {err}")
raise ServiceExceptionError(f"Unable to set locale '{language}' for console: {err}")

info(f'Keyboard language for this installation is now set to: {language}')
else:
Expand All @@ -2074,12 +2080,12 @@ def set_x11_keyboard_language(self, language: str) -> bool:
return False

with Boot(self.target) as session:
session.SysCommand(['localectl', 'set-x11-keymap', '""'])
session.sys_command(['localectl', 'set-x11-keymap', '""'])

try:
session.SysCommand(['localectl', 'set-x11-keymap', language])
session.sys_command(['localectl', 'set-x11-keymap', language])
except SysCallError as err:
raise ServiceException(f"Unable to set locale '{language}' for X11: {err}")
raise ServiceExceptionError(f"Unable to set locale '{language}' for X11: {err}")
else:
info('X11-Keyboard language was not changed from default (no language specified)')

Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/locale/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

from archinstall.lib.command import SysCommand
from archinstall.lib.exceptions import ServiceException, SysCallError
from archinstall.lib.exceptions import ServiceExceptionError, SysCallError
from archinstall.lib.log import error
from archinstall.lib.utils.util import running_from_iso

Expand Down Expand Up @@ -103,7 +103,7 @@ def set_kb_layout(locale: str) -> bool:
try:
SysCommand(f'localectl set-keymap {locale}')
except SysCallError as err:
raise ServiceException(f"Unable to set locale '{locale}' for console: {err}")
raise ServiceExceptionError(f"Unable to set locale '{locale}' for console: {err}")

return True

Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Units(Enum):

class Unit(Enum):
B = 1 # byte
kB = 1000**1 # kilobyte
kB = 1000**1 # kilobyte # noqa: N815
MB = 1000**2 # megabyte
GB = 1000**3 # gigabyte
TB = 1000**4 # terabyte
Expand Down
8 changes: 4 additions & 4 deletions archinstall/lib/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from urllib.parse import urlencode
from urllib.request import urlopen

from archinstall.lib.exceptions import DownloadTimeout, SysCallError
from archinstall.lib.exceptions import DownloadTimeoutError, SysCallError
from archinstall.lib.log import debug, error, info
from archinstall.lib.pacman.pacman import Pacman

Expand All @@ -28,7 +28,7 @@ def __init__(self, timeout: int = 5) -> None:
"""
Args:
timeout:
The download timeout in seconds. The DownloadTimeout exception
The download timeout in seconds. The DownloadTimeoutError exception
will be raised in the context after this many seconds.
"""
self.time: float | None = None
Expand All @@ -39,9 +39,9 @@ def __init__(self, timeout: int = 5) -> None:

def raise_timeout(self, _signl: int, _frame: FrameType | None) -> None:
"""
Raise the DownloadTimeout exception.
Raise the DownloadTimeoutError exception.
"""
raise DownloadTimeout(f'Download timed out after {self.timeout} second(s).')
raise DownloadTimeoutError(f'Download timed out after {self.timeout} second(s).')

def __enter__(self) -> Self:
if self.timeout > 0:
Expand Down
6 changes: 3 additions & 3 deletions archinstall/lib/user/user_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ def _check_for_correct_username(self, username: str | None) -> str | None:
return tr('The username you entered is invalid')

async def _add_user(self) -> User | None:
editResult = await Input(
edit_result = await Input(
tr('Enter a username'),
allow_skip=True,
validator_callback=self._check_for_correct_username,
).show()

match editResult.type_:
match edit_result.type_:
case ResultType.Skip:
return None
case ResultType.Selection:
username = editResult.get_value()
username = edit_result.get_value()
case _:
raise ValueError('Unhandled result type')

Expand Down
8 changes: 4 additions & 4 deletions archinstall/tui/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ def compose(self) -> ComposeResult:
with Vertical(classes='list-container'):
yield option_list
else:
Container = Horizontal if self._preview_location == 'right' else Vertical
container = Horizontal if self._preview_location == 'right' else Vertical
rule_orientation: Literal['horizontal', 'vertical'] = 'vertical' if self._preview_location == 'right' else 'horizontal'

with Container():
with container():
yield option_list
yield Rule(orientation=rule_orientation)
preview_label = Label('', id='preview_content', markup=False)
Expand Down Expand Up @@ -541,10 +541,10 @@ def compose(self) -> ComposeResult:
with Vertical(classes='list-container'):
yield selection_list
else:
Container = Horizontal if self._preview_location == 'right' else Vertical
container = Horizontal if self._preview_location == 'right' else Vertical
rule_orientation: Literal['horizontal', 'vertical'] = 'vertical' if self._preview_location == 'right' else 'horizontal'

with Container():
with container():
yield selection_list
yield Rule(orientation=rule_orientation)
preview_label = Label('', id='preview_content', markup=False)
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ select = [
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"N", # pep8-naming
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLC", # Pylint conventions
Expand Down Expand Up @@ -233,6 +234,11 @@ ignore = [
"W191", # tab-indentation
]

[tool.ruff.lint.per-file-ignores]
"stubs/**/*.pyi" = [
"N", # pep8-naming
]

[tool.ruff.lint.flake8-gettext]
function-names = [
"tr",
Expand Down
Loading