added and removed startup checks

This commit is contained in:
Ranomier 2025-01-16 03:24:23 +01:00
parent b8eb7b0ef8
commit ea915b787b

18
wifi.py
View file

@ -4,11 +4,11 @@
import subprocess as sp import subprocess as sp
import sys import sys
import argparse import argparse
from shutil import which
CFG = { CFG = {
"nmcli": { "nmcli": {
#"device": "",
"fields": ["ssid", "signal", "security", "chan", "rate", "mode", "bssid"], "fields": ["ssid", "signal", "security", "chan", "rate", "mode", "bssid"],
}, },
"rfkill": { "rfkill": {
@ -16,8 +16,18 @@ CFG = {
} }
} }
if not CFG["nmcli"]["fields"][0].lower() == "ssid": def _startup_check():
raise NotImplementedError("ssid must be the first element in fields, will hopefully be fixed in the future") #if not CFG["nmcli"]["fields"][0].lower() == "ssid":
# raise NotImplementedError("ssid must be the first element in fields, will hopefully be fixed in the future")
binary_depencies = ["nmcli", "rfkill"]
gathered_missing = []
for binary in binary_depencies:
if which(binary) is None:
gathered_missing.append(binary)
if gathered_missing:
raise OSError("missing the following binaries: " + str(gathered_missing).strip("[]"))
def _split_blocks(text: str) -> list: def _split_blocks(text: str) -> list:
@ -99,8 +109,8 @@ def connect(ssid: str) -> bool:
def main(): def main():
_startup_check()
try: try:
ap = argparse.ArgumentParser() ap = argparse.ArgumentParser()
ap.add_argument("-j", "--json", help="just output current scanned wifi as json", action="store_true") ap.add_argument("-j", "--json", help="just output current scanned wifi as json", action="store_true")
args = ap.parse_args() args = ap.parse_args()