Replace sys.exit calls with return values (#4156)

This commit is contained in:
codefiles 2026-01-21 21:58:40 -05:00 committed by GitHub
parent 4d2864ba76
commit 192aff0b94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 13 deletions

View File

@ -1,4 +1,6 @@
import sys
from archinstall.main import main
if __name__ == '__main__':
main()
sys.exit(main())

View File

@ -32,7 +32,7 @@ def _log_sys_info() -> None:
debug(f'Disk states before installing:\n{disk_layouts()}')
def _check_online() -> None:
def _check_online() -> bool:
try:
ping('1.1.1.1')
except OSError as ex:
@ -40,10 +40,12 @@ def _check_online() -> None:
if not arch_config_handler.args.skip_wifi_check:
success = not wifi_handler.setup()
if not success:
sys.exit(0)
return False
return True
def _fetch_arch_db() -> None:
def _fetch_arch_db() -> bool:
info('Fetching Arch Linux package database...')
try:
Pacman.run('-Sy')
@ -55,7 +57,9 @@ def _fetch_arch_db() -> None:
error('Run archinstall --debug and check /var/log/archinstall/install.log for details.')
debug(f'Failed to sync Arch Linux package database: {e}')
sys.exit(1)
return False
return True
def run() -> int:
@ -75,8 +79,11 @@ def run() -> int:
_log_sys_info()
if not arch_config_handler.args.offline:
_check_online()
_fetch_arch_db()
if not _check_online():
return 0
if not _fetch_arch_db():
return 1
if not arch_config_handler.args.skip_version_check:
upgrade = check_version_upgrade()

View File

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

View File

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

View File

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