netutils: a set of networking utilities for Python.
Copyright 2010 by Akkana Peck <akkana@shallowsky.com>
... share and enjoy under the GPLv2 or (at your option) later.
Provides the following:
Classes:
NetInterface: name, ip, broadcast, netmask, essid, encryption, wireless
AccessPoint : address, essid, encryption, quality, interface
Route : display or change network routing tables.
Functions outside of classes:
get_interfaces(only_up=False): returns a list of all NetInterface.
If only_up, will only return the ones currently marked UP.
get_wireless_interfaces(): returns a list of wireless NetInterface.
get_accesspoints(): returns a list of visible AccessPoints.
ifdown_all(): take all interfaces down, killing any wpa_supplicant or dhcp
kill_by_name(namelist): Kill a any running processes that include any
of the names in namelist. Return a list of actual process names killed.
Classes |
| |
- AccessPoint
- NetInterface
- Route
class Route |
|
Network routing table entry: one line from route -n |
|
Methods defined here:
- __init__(self, *args)
- # Route(line)
# Route(dest, gateway, iface, mask=None) :
- __repr__(self)
- Return a string representing the route
- add(self)
- Add this route to the routing tables.
- call_route(self, cmd)
- Backend routine to call the system route command.
cmd is either "add" or "delete".
Users should normally call add() or delete() instead.
- delete(self)
- Remove this route from the routing tables.
- init_from_line(self, line)
- init from a line from route -n, such as:
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
Static methods defined here:
- read_route_table()
- Read the system routing table, returning a list of Routes.
| |
Functions |
| |
- get_accesspoints()
- Return a list of visible wireless accesspoints.
- get_interfaces(only_up=False)
- Returns a list of NetInterfaces for all eth*, wlan* or mlan*
interfaces visible from ifconfig.
Omit lo, vpn, ipv6 and other non-physical interfaces.
If only_up is true, use ifconfig instead if ifconfig -a.
- get_wireless_interfaces()
- Returns a list of wireless interfaces available.
- ifdown_all()
- Take all current interfaces down.
- kill_by_name(namelist)
- Kills all running processes that start with any of the
strings in the given name list.
|