diff --git a/wifi.py b/wifi.py index 6f54750..8066af5 100755 --- a/wifi.py +++ b/wifi.py @@ -4,11 +4,11 @@ import subprocess as sp import sys import argparse +from shutil import which CFG = { "nmcli": { - #"device": "", "fields": ["ssid", "signal", "security", "chan", "rate", "mode", "bssid"], }, "rfkill": { @@ -16,8 +16,18 @@ CFG = { } } -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") +def _startup_check(): + #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: @@ -99,8 +109,8 @@ def connect(ssid: str) -> bool: def main(): + _startup_check() try: - ap = argparse.ArgumentParser() ap.add_argument("-j", "--json", help="just output current scanned wifi as json", action="store_true") args = ap.parse_args()