added and removed startup checks
This commit is contained in:
parent
b8eb7b0ef8
commit
ea915b787b
1 changed files with 14 additions and 4 deletions
18
wifi.py
18
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()
|
||||
|
|
Loading…
Add table
Reference in a new issue