コード例 #1
0
ファイル: interfaces.py プロジェクト: era16102/misc-scripts
def main():
    network_interfaces = SCNetworkInterfaceCopyAll()
    print get_networkinterfacelist(network_interfaces)

    prefs = SCPreferencesCreate(None, 'foo', None)
    network_services = SCNetworkServiceCopyAll(prefs)
    print get_networkservices(network_services)
コード例 #2
0
def fact():
    '''Return the value of the computername of this Mac'''
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = []
    for interface in network_interfaces:
        interfaces.append(SCNetworkInterfaceGetLocalizedDisplayName(interface))

    return {factoid: interfaces}
コード例 #3
0
ファイル: netdev_query.py プロジェクト: rudresh2319/Xpra
def get_interface_info(_fd, iface):
    r = SCNetworkInterfaceCopyAll()
    if iface:
        for scnetworkinterface in r:
            if str(SCNetworkInterfaceGetBSDName(scnetworkinterface))==iface:
                return do_get_interface_info(scnetworkinterface)
    elif len(r)==1:
        return do_get_interface_info(r[0])
    return {}
コード例 #4
0
ファイル: wifi_interface.py プロジェクト: ulte/unearth
def interfaces():
    '''Returns a list of all network interface names'''
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = {}
    for interface in network_interfaces:
        interfaces[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
            SCNetworkInterfaceGetBSDName(interface),
            SCNetworkInterfaceGetHardwareAddressString(interface))
    return interfaces
コード例 #5
0
def fact():
    """Returns a list of all network interface names"""
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = {}
    for interface in network_interfaces:
        interfaces[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
            SCNetworkInterfaceGetBSDName(interface),
            SCNetworkInterfaceGetHardwareAddressString(interface),
        )

    return {factoid: str(interfaces)}
コード例 #6
0
def fact():
    '''Returns the mac address of this Mac'''
    net_config = SCDynamicStoreCreate(None, "net", None, None)
    states = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/IPv4")
    primary_interface = states["PrimaryInterface"]
    primary_device = [
        x for x in SCNetworkInterfaceCopyAll()
        if SCNetworkInterfaceGetBSDName(x) == primary_interface
    ][0]
    primary_MAC = SCNetworkInterfaceGetHardwareAddressString(primary_device)
    return {factoid: primary_MAC}
コード例 #7
0
def get_wifi_interface():
    """Returns the name of the wifi interface."""
    network_interfaces = SCNetworkInterfaceCopyAll()
    interfaces = {}
    for interface in network_interfaces:
        interfaces[SCNetworkInterfaceGetLocalizedDisplayName(interface)] = (
            SCNetworkInterfaceGetBSDName(interface),
            SCNetworkInterfaceGetHardwareAddressString(interface),
        )
    wifi_interface = None
    try:
        wifi_interface = interfaces["Wi-Fi"][0]
    except KeyError:
        pass
    return wifi_interface
コード例 #8
0
def fact():
    """Return the active network interfaces"""
    result = []

    interfaces = [
        SCNetworkInterfaceGetBSDName(i) for i in SCNetworkInterfaceCopyAll()
    ]

    for i in interfaces:
        try:
            active = subprocess.check_output(
                ["/usr/sbin/ipconfig", "getifaddr", i]).strip()
            if active:
                result.append(i)
        except subprocess.CalledProcessError:
            continue

    return {factoid: result}
コード例 #9
0
ファイル: localmcx.py プロジェクト: jrjsmrtn/munki
def get_en0_mac():
    '''Returns the MAC layer address of en0'''
    for interface in SCNetworkInterfaceCopyAll():
        if SCNetworkInterfaceGetBSDName(interface) == "en0":
            return SCNetworkInterfaceGetHardwareAddressString(interface)
    return None
コード例 #10
0
ファイル: netdev_query.py プロジェクト: rudresh2319/Xpra
def main():
    r = SCNetworkInterfaceCopyAll()
    print("%i interfaces:" % len(r))
    for scnetworkinterface in r:
        info = do_get_interface_info(scnetworkinterface)
        print(info)
コード例 #11
0
ファイル: renew_dhcp_lease.py プロジェクト: nathan8299/pylab
def update_dhcp(interface):
    interfaces = SCNetworkInterfaceCopyAll()
    for i in interfaces:
        if SCNetworkInterfaceGetBSDName(i) == interface:
            return SCNetworkInterfaceForceConfigurationRefresh(i)
    return False