A simple Python library for dealing with the /etc/network/interfaces file in most Debian based distributions.
Project description
This is a simple Python library for dealing with the /etc/network/interfaces file in most Debian based distributions. This is forked from https://github.com/dggreenbaum/debinterface to refactor it and maybe extends it with wpa_supplicant handling
Documentation : http://debinterface.readthedocs.io/en/latest/index.html
Example usage
import debinterface
# Get a collection of objects representing the network adapters.
adapters = debinterface.Interfaces().adapters
# You get a list you can iterare over.
# Each adapter has an 'export()' method that returns a dictionary of its options.
# You can print the name of each adapter as follows:
for adapter in adapters:
item = adapter.export()
print(item['name'])
# Write your new interfaces file as follows:
# Any changes made with setter methods will be reflected with the new write.
interfaces = debinterface.Interfaces()
interfaces.writeInterfaces()
# A backup of your old interfaces file will be generated when writing over the previous interfaces file
# By defaults these paths are used :
# INTERFACES_PATH='/etc/network/interfaces'
# BACKUP_PATH='/etc/network/interfaces.old'
# Paths can be customized when instanciating the Interfaces class:
interfaces = debinterface.Interfaces(interfaces_path='/home/interfaces', backup_path='/another/custom/path')
# By defaults, interfaces file is read when instanciating the Interfaces class, to do it lazyly:
interfaces = debinterface.Interfaces(update_adapters=False)
interfaces.updateAdapters()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
debinterface-3.1.0.tar.gz
(29.1 kB
view hashes)
Built Distribution
Close
Hashes for debinterface-3.1.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47034656390dcadf5fad391ccdb3e30555f3912dd62b6b9a9a81b811e37d6891 |
|
MD5 | f7481c24dfa03c5b8715cda4bfcceae5 |
|
BLAKE2b-256 | 1b213d1e4618b0137e1dd6e9cc0d9fc8c52afc5ab482d5ffb1e06ee07408aba3 |