Use sys.exit instead of exit (#4120)

This commit is contained in:
codefiles 2026-01-12 15:51:08 -05:00 committed by GitHub
parent 82512eed0e
commit f6eca309ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 20 additions and 13 deletions

View File

@ -48,7 +48,7 @@ def _check_online() -> None:
if not arch_config_handler.args.skip_wifi_check: if not arch_config_handler.args.skip_wifi_check:
success = not wifi_handler.setup() success = not wifi_handler.setup()
if not success: if not success:
exit(0) sys.exit(0)
def _fetch_arch_db() -> None: def _fetch_arch_db() -> None:
@ -63,7 +63,7 @@ def _fetch_arch_db() -> None:
error('Run archinstall --debug and check /var/log/archinstall/install.log for details.') error('Run archinstall --debug and check /var/log/archinstall/install.log for details.')
debug(f'Failed to sync Arch Linux package database: {e}') debug(f'Failed to sync Arch Linux package database: {e}')
exit(1) sys.exit(1)
def check_version_upgrade() -> str | None: def check_version_upgrade() -> str | None:
@ -151,7 +151,7 @@ def run_as_a_module() -> None:
warn(text) warn(text)
rc = 1 rc = 1
exit(rc) sys.exit(rc)
__all__ = [ __all__ = [

View File

@ -1,6 +1,7 @@
import argparse import argparse
import json import json
import os import os
import sys
import urllib.error import urllib.error
import urllib.parse import urllib.parse
from argparse import ArgumentParser, Namespace from argparse import ArgumentParser, Namespace
@ -266,7 +267,7 @@ class ArchConfigHandler:
self._config.version = self._get_version() self._config.version = self._get_version()
except ValueError as err: except ValueError as err:
warn(str(err)) warn(str(err))
exit(1) sys.exit(1)
@property @property
def config(self) -> ArchConfig: def config(self) -> ArchConfig:
@ -492,7 +493,7 @@ class ArchConfigHandler:
except ValueError as err: except ValueError as err:
if 'Invalid password' in str(err): if 'Invalid password' in str(err):
error(tr('Incorrect credentials file decryption password')) error(tr('Incorrect credentials file decryption password'))
exit(1) sys.exit(1)
else: else:
debug(f'Error decrypting credentials file: {err}') debug(f'Error decrypting credentials file: {err}')
raise err from err raise err from err
@ -537,12 +538,12 @@ class ArchConfigHandler:
else: else:
error('Not a valid url') error('Not a valid url')
exit(1) sys.exit(1)
def _read_file(self, path: Path) -> str: def _read_file(self, path: Path) -> str:
if not path.exists(): if not path.exists():
error(f'Could not find file {path}') error(f'Could not find file {path}')
exit(1) sys.exit(1)
return path.read_text() return path.read_text()

View File

@ -1,3 +1,4 @@
import sys
from typing import override from typing import override
from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
@ -174,7 +175,7 @@ class GlobalMenu(AbstractMenu[None]):
), ),
MenuItem( MenuItem(
text=tr('Abort'), text=tr('Abort'),
action=lambda x: exit(1), action=lambda x: sys.exit(1),
key=f'{CONFIG_KEY}_abort', key=f'{CONFIG_KEY}_abort',
), ),
] ]

View File

@ -1,3 +1,4 @@
import sys
from enum import Enum from enum import Enum
from pathlib import Path from pathlib import Path
from typing import assert_never from typing import assert_never
@ -305,4 +306,4 @@ def ask_abort() -> None:
).run() ).run()
if result.item() == MenuItem.yes(): if result.item() == MenuItem.yes():
exit(0) sys.exit(0)

View File

@ -1,3 +1,4 @@
import sys
import time import time
from collections.abc import Callable from collections.abc import Callable
from pathlib import Path from pathlib import Path
@ -35,7 +36,7 @@ class Pacman:
if time.time() - started > (60 * 10): if time.time() - started > (60 * 10):
error(tr('Pre-existing pacman lock never exited. Please clean up any existing pacman sessions before using archinstall.')) error(tr('Pre-existing pacman lock never exited. Please clean up any existing pacman sessions before using archinstall.'))
exit(1) sys.exit(1)
return SysCommand(f'{default_cmd} {args}') return SysCommand(f'{default_cmd} {args}')

View File

@ -1,4 +1,5 @@
import os import os
import sys
import time import time
from pathlib import Path from pathlib import Path
@ -194,7 +195,7 @@ def guided() -> None:
config.save() config.save()
if arch_config_handler.args.dry_run: if arch_config_handler.args.dry_run:
exit(0) sys.exit(0)
if not arch_config_handler.args.silent: if not arch_config_handler.args.silent:
aborted = False aborted = False

View File

@ -1,3 +1,4 @@
import sys
from pathlib import Path from pathlib import Path
from archinstall.default_profiles.minimal import MinimalProfile from archinstall.default_profiles.minimal import MinimalProfile
@ -69,7 +70,7 @@ def _minimal() -> None:
config.save() config.save()
if arch_config_handler.args.dry_run: if arch_config_handler.args.dry_run:
exit(0) sys.exit(0)
if not arch_config_handler.args.silent: if not arch_config_handler.args.silent:
aborted = False aborted = False

View File

@ -1,3 +1,4 @@
import sys
from pathlib import Path from pathlib import Path
from archinstall import debug, error from archinstall import debug, error
@ -65,7 +66,7 @@ def _only_hd() -> None:
config.save() config.save()
if arch_config_handler.args.dry_run: if arch_config_handler.args.dry_run:
exit(0) sys.exit(0)
if not arch_config_handler.args.silent: if not arch_config_handler.args.silent:
aborted = False aborted = False