Skip to main content

No project description provided

Project description

ixconfig

Quick and simple ifconfig and iwconfig parsing.

Install

pip install ixconfig

Usage

import ixconfig

# ifconfig

# returns an Ifc object - runs `ifconfig`
ifc = ixconfig.Ifc()
# which behaves like a dict
assert ifc['wlan0']['ip'] == "192.168.1.237"
# or an attrdict
assert ifc.wlan0.ip == "192.168.1.237"

# when you pass in an interface, it runs `ifconfig wlan0`
ifc = ixconfig.Ifc('wlan0')
# and then you can just access the attributes directly
assert ifc['ip'] == "192.168.1.237"
assert ifc.ip == "192.168.1.237"

# iwconfig

iwc = ixconfig.Iwc()
assert iwc['wlan0']['quality'] == 92.0
assert iwc.wlan0.quality == 92.0

iwc = ixconfig.Iwc('wlan0')
assert iwc['quality'] == 92.0
assert iwc.quality == 92.0

Notes

This was code that I factored out of another project a while back. Eventually, I think this functionality should be covered ifcfg, but they don't handle iwconfig at the moment.

So until then, this package covers very basic parsing for both ifconfig and iwconfig.

Example Outputs

ifc = ixconfig.Ifc()
iwc = ixconfig.Iwc()
print(ifc)
print(iwc)
( $ ifconfig ) {
    "docker0": {
        "broadcast": "172.17.255.255",
        "ip": "172.17.0.1",
        "ipv6": "fe80::42:f2ff:fe23:bb38",
        "mac": "02:42:f2:23:bb:38",
        "mtu": 1500,
        "name": "docker0",
        "netmask": "255.255.0.0",
        "rx_dropped": 0,
        "rx_errors": 0,
        "rx_overruns": 0,
        "rx_packets": 21326,
        "tx_carrier": 0,
        "tx_collisions": 0,
        "tx_dropped": 0,
        "tx_errors": 0,
        "tx_overruns": 0,
        "tx_packets": 30842
    },
    ...
    "wlan0": {
        "broadcast": "192.168.1.255",
        "ip": "192.168.1.237",
        "ipv6": "fe80::2998:5b3c:8ffb:a03d",
        "mac": "dc:a6:32:5d:df:ce",
        "mtu": 1500,
        "name": "wlan0",
        "netmask": "255.255.255.0",
        "rx_dropped": 0,
        "rx_errors": 0,
        "rx_overruns": 0,
        "rx_packets": 1960938,
        "tx_carrier": 0,
        "tx_collisions": 0,
        "tx_dropped": 0,
        "tx_errors": 0,
        "tx_overruns": 0,
        "tx_packets": 2790429
    }
}

( $ iwconfig ) {
    "wlan0": {
        "access_point": "A0:8E:78:59:45:D2",
        "bitrate": 72.2,
        "bitrate_unit": "Mb/s",
        "freq": 2.462,
        "freq_unit": "GHz",
        "mode": "Managed",
        "name": "wlan0",
        "power_mgmt": "on",
        "quality": 50.0,
        "quality_ratio": 0.7142857142857143,
        "ssid": "MySpectrumWiFicc-2G",
        "strength": -60.0,
        "strength_unit": "dBm"
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ixconfig-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file ixconfig-0.1.0.tar.gz.

File metadata

  • Download URL: ixconfig-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.6

File hashes

Hashes for ixconfig-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18c307be3d200639232b0692fecd50ff9c987e90ff01e6d7b474fadcf5ce22a2
MD5 0ceffcd15d53cb539c8511760f619f66
BLAKE2b-256 502912cf0b0e364b3edf4731a92d7dfd1a6e7488e82b138ffe9d1312f08649c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page