mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-01 05:13:01 +02:00
statd: add BSSID to table of available networks
Also, spruce up the table a bit. Allow it to resize, let the SSID column be flexible, and right-align column(s) with numbers. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -345,8 +345,11 @@ class SimpleTable:
|
||||
# Add separator " " only between columns, not after the last one
|
||||
separator = "" if is_last else " "
|
||||
|
||||
# Don't pad the last column to avoid trailing spaces
|
||||
# Don't add trailing spaces to the last column
|
||||
if is_last:
|
||||
if column.align == 'right':
|
||||
padding = width - visible_len
|
||||
return ' ' * max(0, padding) + value_str
|
||||
return value_str
|
||||
elif column.align == 'right':
|
||||
padding = width - visible_len
|
||||
@@ -1230,22 +1233,26 @@ class Iface:
|
||||
print(row)
|
||||
|
||||
def pr_wifi_ssids(self):
|
||||
print("\nAVAILABLE NETWORKS:")
|
||||
width = 70
|
||||
Decore.title("Available Networks", width)
|
||||
ssid_table = SimpleTable([
|
||||
Column('SSID'),
|
||||
Column('SSID', flexible=True),
|
||||
Column('BSSID'),
|
||||
Column('SECURITY'),
|
||||
Column('SIGNAL'),
|
||||
Column('CHANNEL')
|
||||
])
|
||||
Column('CHANNEL', 'right')
|
||||
], min_width=width)
|
||||
|
||||
station = self.wifi.get("station", {})
|
||||
results = station.get("scan-results", {})
|
||||
for result in results:
|
||||
ssid = result.get('ssid', 'Hidden')
|
||||
bssid = result.get("bssid", "unknown")
|
||||
encstr = ", ".join(result.get("encryption", ["Unknown"]))
|
||||
status = rssi_to_status(result.get("rssi", -100))
|
||||
channel = result.get("channel", "?")
|
||||
|
||||
ssid_table.row(result.get('ssid', 'Hidden'), encstr, status, channel)
|
||||
ssid_table.row(ssid, bssid, encstr, status, channel)
|
||||
ssid_table.print()
|
||||
|
||||
def pr_wifi_stations(self):
|
||||
|
||||
Reference in New Issue
Block a user