Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dggreenbaum/debinterface
A simple Python library for dealing with the /etc/network/interfaces file in most Debian based distributions.
https://github.com/dggreenbaum/debinterface
Last synced: 3 months ago
JSON representation
A simple Python library for dealing with the /etc/network/interfaces file in most Debian based distributions.
- Host: GitHub
- URL: https://github.com/dggreenbaum/debinterface
- Owner: dggreenbaum
- License: bsd-3-clause
- Created: 2012-11-20T01:58:47.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T18:34:53.000Z (over 3 years ago)
- Last Synced: 2024-07-20T11:09:18.805Z (4 months ago)
- Language: Python
- Homepage:
- Size: 67.4 KB
- Stars: 26
- Watchers: 3
- Forks: 49
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#Debinterface
This is a simple Python library for dealing with the /etc/network/interfaces file in most Debian based distributions.
## Changelog:
2.0-beta - September 2014 : refactoring which breaks retrocompatibility
1.0 - Dec 15 2012Read, writing, and editing supported.
Specify file locations in constants.py
May thanks to yan12125 (https://github.com/yan12125/debinterface)## 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()