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
3 changes: 0 additions & 3 deletions archinstall/lib/network/wifi_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,3 @@ def _get_scan_results(self, iface: str) -> list[WifiNetwork]:
except SysCallError as err:
debug('Unable to retrieve wifi results')
raise err


wifi_handler = WifiHandler()
13 changes: 9 additions & 4 deletions archinstall/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from archinstall.lib.args import arch_config_handler
from archinstall.lib.disk.utils import disk_layouts
from archinstall.lib.general import running_from_host
from archinstall.lib.network.wifi_handler import wifi_handler
from archinstall.lib.network.wifi_handler import WifiHandler
from archinstall.lib.networking import ping
from archinstall.lib.packages.packages import check_version_upgrade

Expand All @@ -32,12 +32,12 @@ def _log_sys_info() -> None:
debug(f'Disk states before installing:\n{disk_layouts()}')


def _check_online() -> bool:
def _check_online(wifi_handler: WifiHandler | None = None) -> bool:
try:
ping('1.1.1.1')
except OSError as ex:
if 'Network is unreachable' in str(ex):
if not arch_config_handler.args.skip_wifi_check:
if wifi_handler is not None:
success = not wifi_handler.setup()
if not success:
return False
Expand Down Expand Up @@ -79,7 +79,12 @@ def run() -> int:
_log_sys_info()

if not arch_config_handler.args.offline:
if not _check_online():
if not arch_config_handler.args.skip_wifi_check:
wifi_handler = WifiHandler()
else:
wifi_handler = None

if not _check_online(wifi_handler):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benefit in making this an optional parameter instead of creating the instance inside _check_online and avoiding the overhead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, testability.

return 0

if not _fetch_arch_db():
Expand Down