Skip to content

Commit 1cc309f

Browse files
committed
Replace sys.exit calls with return values
1 parent 4d2864b commit 1cc309f

5 files changed

Lines changed: 19 additions & 13 deletions

File tree

archinstall/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import sys
2+
13
from archinstall.main import main
24

35
if __name__ == '__main__':
4-
main()
6+
sys.exit(main())

archinstall/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,20 @@ def _log_sys_info() -> None:
3232
debug(f'Disk states before installing:\n{disk_layouts()}')
3333

3434

35-
def _check_online() -> None:
35+
def _check_online() -> bool:
3636
try:
3737
ping('1.1.1.1')
3838
except OSError as ex:
3939
if 'Network is unreachable' in str(ex):
4040
if not arch_config_handler.args.skip_wifi_check:
4141
success = not wifi_handler.setup()
4242
if not success:
43-
sys.exit(0)
43+
return False
4444

45+
return True
4546

46-
def _fetch_arch_db() -> None:
47+
48+
def _fetch_arch_db() -> bool:
4749
info('Fetching Arch Linux package database...')
4850
try:
4951
Pacman.run('-Sy')
@@ -55,7 +57,9 @@ def _fetch_arch_db() -> None:
5557
error('Run archinstall --debug and check /var/log/archinstall/install.log for details.')
5658

5759
debug(f'Failed to sync Arch Linux package database: {e}')
58-
sys.exit(1)
60+
return False
61+
62+
return True
5963

6064

6165
def run() -> int:
@@ -75,8 +79,11 @@ def run() -> int:
7579
_log_sys_info()
7680

7781
if not arch_config_handler.args.offline:
78-
_check_online()
79-
_fetch_arch_db()
82+
if not _check_online():
83+
return 0
84+
85+
if not _fetch_arch_db():
86+
return 1
8087

8188
if not arch_config_handler.args.skip_version_check:
8289
upgrade = check_version_upgrade()

archinstall/scripts/guided.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import sys
32
import time
43
from pathlib import Path
54

@@ -192,7 +191,7 @@ def guided() -> None:
192191
config.save()
193192

194193
if arch_config_handler.args.dry_run:
195-
sys.exit(0)
194+
return
196195

197196
if not arch_config_handler.args.silent:
198197
aborted = False

archinstall/scripts/minimal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from pathlib import Path
32

43
from archinstall.default_profiles.minimal import MinimalProfile
@@ -68,7 +67,7 @@ def _minimal() -> None:
6867
config.save()
6968

7069
if arch_config_handler.args.dry_run:
71-
sys.exit(0)
70+
return
7271

7372
if not arch_config_handler.args.silent:
7473
aborted = False

archinstall/scripts/only_hd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from pathlib import Path
32

43
from archinstall.lib.args import arch_config_handler
@@ -64,7 +63,7 @@ def _only_hd() -> None:
6463
config.save()
6564

6665
if arch_config_handler.args.dry_run:
67-
sys.exit(0)
66+
return
6867

6968
if not arch_config_handler.args.silent:
7069
aborted = False

0 commit comments

Comments
 (0)