示例#1
0
文件: wifi.py 项目: jamesruan/pybtsp
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}
示例#2
0
文件: wifi.py 项目: jamesruan/pybtsp
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}
示例#3
0
文件: wifi.py 项目: jamesruan/pybtsp
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}