Example #1
0
def getEthernetConnection():
    fields = 'NAME,UUID,TYPE,DEVICE'
    args = ['env', 'LC_ALL=C', 'nmcli', '-t', '-f', fields, 'connection']
    ok, out = runSubProc(args)
    if ok:
        va = nmcli.parse(out)
        r = {}
        for i in va:
            name, uuid, type, device = i
            if type == "802-3-ethernet":
                r[uuid] = {"name": name, "device": device}
        return r
    else:
        return {"error": out}
Example #2
0
def getEthernetInterface():
    fields = 'DEVICE,TYPE,STATE'
    args = ['env', 'LC_ALL=C', 'nmcli', '-t', '-f', fields, 'device']
    ok, out = runSubProc(args)
    if ok:
        va = nmcli.parse(out)
        r = {}
        for i in va:
            device, type, state = i
            if type == "ethernet" and state != "unmanaged":
                r[device] = state
        return r
    else:
        return {"error": out}
Example #3
0
def getScanResult():
    fields = 'SSID,MODE,CHAN,RATE,SIGNAL,SECURITY'
    args = ['env', 'LC_ALL=C', 'nmcli', '-t', '-f', fields, 'device', 'wifi']
    ok, out = runSubProc(args)
    if ok:
        va = nmcli.parse(out)
        r = {}
        for i in va:
            ssid, mode, chan, rate, signal, enc = i
            r[ssid] = {
                "mode": mode,
                "channel": chan,
                "rate": rate,
                "signal": signal,
                "encryption": enc
            }
        return r
    else:
        return {"error": out}