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
Complete documentation is on Read the docs
Example usage
You’ll find way more examples here
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()
Run the tests
pip install -r requirements_dev.txt
py.test --cov=debinterface test
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.5.0.tar.gz
(438.6 kB
view details)
File details
Details for the file debinterface-3.5.0.tar.gz
.
File metadata
- Download URL: debinterface-3.5.0.tar.gz
- Upload date:
- Size: 438.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6661c10323945278ad2190c54a04fa74cf69f9a1ea0c6ea2e63a14a55669a822 |
|
MD5 | fb95c85a64a01a623f22fb06b8911303 |
|
BLAKE2b-256 | 8d9f63e86a83cc0003150435ea7a620f563ba91babeca5225d7a96f22dc9a9dd |