Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/networking.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-01-25 12:38:11 +0100
committerAnton Hvornum <anton.feeds@gmail.com>2021-01-25 12:38:11 +0100
commit3a16d156b946e5a6282b8c364e406cf0b4adea44 (patch)
treec531b381df0d21073dad3f84cdcc7e935ce1fe62 /archinstall/lib/networking.py
parent7358dc5a03b0652132ca9debba2aeb43f3610f2b (diff)
Added an embryo for listing wireless networks.
Diffstat (limited to 'archinstall/lib/networking.py')
-rw-r--r--archinstall/lib/networking.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py
index b69a43db..882bcff3 100644
--- a/archinstall/lib/networking.py
+++ b/archinstall/lib/networking.py
@@ -3,6 +3,9 @@ import fcntl
import socket
import struct
from collections import OrderedDict
+from .exceptions import *
+from .general import sys_command
+from .storage import storage
def getHwAddr(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -37,4 +40,29 @@ def enrichIfaceTypes(interfaces :dict):
return result
def get_interface_from_mac(mac):
- return list_interfaces().get(mac.lower(), None) \ No newline at end of file
+ return list_interfaces().get(mac.lower(), None)
+
+def wirelessScan(interface):
+ interfaces = enrichIfaceTypes(list_interfaces().values())
+ if interfaces[interface] != 'WIRELESS':
+ raise HardwareIncompatibilityError(f"Interface {interface} is not a wireless interface: {interfaces}")
+
+ sys_command(f"iwctl station {interface} scan")
+
+ if not '_WIFI' in storage:
+ storage['_WIFI'] = {}
+ if not interface in storage['_WIFI']:
+ storage['_WIFI'][interface] = {}
+
+ storage['_WIFI'][interface]['scanning'] = True
+
+# TOOD: Full WiFi experience might get evolved in the future, pausing for now 2021-01-25
+def getWirelessNetworks(interface):
+ # TODO: Make this oneliner pritter to check if the interface is scanning or not.
+ if not '_WIFI' in storage or interface not in storage['_WIFI'] or storage['_WIFI'][interface].get('scanning', False) is False:
+ import time
+ wirelessScan(interface)
+ time.sleep(5)
+
+ for line in sys_command(f"iwctl station {interface} get-networks"):
+ print(line) \ No newline at end of file