Skip to content

Commit af160ca

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

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

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: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ 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:
41-
success = not wifi_handler.setup()
42-
if not success:
43-
sys.exit(0)
41+
if wifi_handler.setup():
42+
return False
4443

44+
return True
4545

46-
def _fetch_arch_db() -> None:
46+
47+
def _fetch_arch_db() -> bool:
4748
info('Fetching Arch Linux package database...')
4849
try:
4950
Pacman.run('-Sy')
@@ -55,7 +56,9 @@ def _fetch_arch_db() -> None:
5556
error('Run archinstall --debug and check /var/log/archinstall/install.log for details.')
5657

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

6063

6164
def run() -> int:
@@ -75,8 +78,11 @@ def run() -> int:
7578
_log_sys_info()
7679

7780
if not arch_config_handler.args.offline:
78-
_check_online()
79-
_fetch_arch_db()
81+
if not _check_online():
82+
return 0
83+
84+
if not _fetch_arch_db():
85+
return 1
8086

8187
if not arch_config_handler.args.skip_version_check:
8288
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)