예제 #1
0
파일: link.py 프로젝트: alihanozturk/kuller
def kernelEvent(data):
    type, dir = data.split("@", 1)
    if not dir.startswith("/class/net/"):
        return
    devname = dir[11:]
    flag = 1
    
    if type == "add":
        ifc = network.IF(devname)
        if ifc.isWireless():
            return
        devuid = ifc.deviceUID()
        notify("Net.Link.deviceChanged", "added net %s %s" % (devuid, network.deviceName(devuid)))
        conns = instances("name")
        for conn in conns:
            dev = Dev(conn)
            if dev.ifc and dev.ifc.name == devname:
                if dev.state == "up":
                    dev.up()
                    return
                flag = 0
        if flag:
            notify("Net.Link.deviceChanged", "new net %s %s" % (devuid, network.deviceName(devuid)))
    
    elif type == "remove":
        conns = instances("name")
        for conn in conns:
            dev = Dev(conn)
            # FIXME: dev.ifc is not enough :(
            if dev.ifc and dev.ifc.name == devname:
                if dev.state == "up":
                    notify("Net.Link.stateChanged", dev.name + "\ninaccessible " + "Device removed")
        notify("Net.Link.deviceChanged", "removed net %s" % devname)
예제 #2
0
def kernelEvent(data):
    type, dir = data.split("@", 1)
    if not dir.startswith("/class/net/"):
        return
    devname = dir[11:]
    flag = 1
    
    ifc = network.IF(devname)
    if type == "add":
        if not ifc.isWireless():
            return
        devuid = ifc.deviceUID()
        notify("Net.Link.deviceChanged", "added wifi %s %s" % (devuid, network.deviceName(devuid)))
        conns = instances("name")
        for conn in conns:
            dev = Dev(conn)
            if dev.ifc and dev.ifc.name == devname:
                if dev.state == "up":
                    dev.up()
                    return
                flag = 0
        if flag:
            notify("Net.Link.deviceChanged", "new wifi %s %s" % (devuid, network.deviceName(devuid)))
    
    elif type == "remove":
        conns = instances("name")
        for conn in conns:
            dev = Dev(conn)
            # FIXME: ifc is not enough here :(
            if dev.ifc and dev.ifc.name == devname:
                if dev.state == "up":
                    notify("Net.Link.stateChanged", dev.name + "\ninaccessible " + "Device removed")
        notify("Net.Link.deviceChanged", "removed wifi %s" % devname)
예제 #3
0
def connectionInfo(name=None):
    dev = Dev(name, True)
    s = "name=%s" % name
    if dev.uid:
        s += "\ndevice_id=%s\ndevice_name=%s" % (dev.uid,
                                                 network.deviceName(dev.uid))
    s += "\nnet_mode=%s" % dev.mode
    if dev.address:
        s += "\nnet_address=%s" % dev.address
    if dev.mask:
        s += "\nnet_mask=%s" % dev.mask
    if dev.gateway:
        s += "\nnet_gateway=%s" % dev.gateway
    s += "\nnamemode=%s" % dev.namemode
    if dev.nameserver:
        s += "\nnameserver=%s" % dev.nameserver
    if dev.state == "up":
        if dev.ifc:
            if dev.mode == "auto":
                if dev.ifc.isAuto() and dev.ifc.isUp():
                    state = "up " + dev.ifc.getAddress()[0]
                else:
                    state = "inaccessible " + _(dhcp_fail_msg)
            else:
                if dev.ifc.isUp():
                    state = "up " + dev.ifc.getAddress()[0]
        else:
            state = "inaccessible " + _(no_device_msg)
    else:
        if dev.ifc:
            state = "down"
        else:
            state = "unavailable"
    s += "\nstate=%s" % state
    return s
예제 #4
0
파일: link.py 프로젝트: blue-devil/kuller
def connectionInfo(name=None):
    dev = Dev(name, True)
    s = "name=%s" % name
    if dev.uid:
        s += "\ndevice_id=%s\ndevice_name=%s" % (dev.uid, network.deviceName(dev.uid))
    s += "\nnet_mode=%s" % dev.mode
    if dev.address:
        s += "\nnet_address=%s" % dev.address
    if dev.mask:
        s += "\nnet_mask=%s" % dev.mask
    if dev.gateway:
        s += "\nnet_gateway=%s" % dev.gateway
    s += "\nnamemode=%s" % dev.namemode
    if dev.nameserver:
        s += "\nnameserver=%s" % dev.nameserver
    if dev.state == "up":
        if dev.ifc:
            if dev.mode == "auto":
                if dev.ifc.isAuto() and dev.ifc.isUp():
                    state = "up " + dev.ifc.getAddress()[0]
                else:
                    state = "inaccessible " + _(dhcp_fail_msg)
            else:
                if dev.ifc.isUp():
                    state = "up " + dev.ifc.getAddress()[0]
        else:
            state = "inaccessible " + _(no_device_msg)
    else:
        if dev.ifc:
            state = "down"
        else:
            state = "unavailable"
    s += "\nstate=%s" % state
    return s
예제 #5
0
def deviceList():
    iflist = []
    for ifc in network.interfaces():
        if ifc.isEthernet() and not ifc.isWireless():
            uid = ifc.deviceUID()
            info = network.deviceName(uid)
            iflist.append("%s %s" % (uid, info))
    return "\n".join(iflist)
예제 #6
0
파일: link.py 프로젝트: alihanozturk/kuller
def deviceList():
    iflist = []
    for ifc in network.interfaces():
        if ifc.isEthernet() and not ifc.isWireless():
            uid = ifc.deviceUID()
            info = network.deviceName(uid)
            iflist.append("%s %s" % (uid, info))
    return "\n".join(iflist)