Skip to main content
Help us improve Python packaging – donate today!

A simple Python library for dealing with the /etc/network/interfaces file in most Debian based distributions.

Project Description

https://travis-ci.org/nMustaki/debinterface.svg?branch=master

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

Release history Release notifications

This version
History Node

3.3.0

History Node

3.2.1

History Node

3.2.0

History Node

3.1.0

History Node

3.0.1

History Node

3.0.0

History Node

2.3.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
debinterface-3.3.0-py2-none-any.whl (21.1 kB) Copy SHA256 hash SHA256 Wheel py2 Jan 27, 2018
debinterface-3.3.0.tar.gz (438.3 kB) Copy SHA256 hash SHA256 Source None Jan 27, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page