Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release series with Windows support #7

Merged
merged 27 commits into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f7a6444
Move pkg to src/ folder structure, use Tox for testing, add python 3.…
benjaoming Jul 20, 2017
0fa269c
Fix encoding, this fixes default_interface (BROKEN!)
benjaoming Jul 20, 2017
261a17b
Add pre-commit hooks and fix linting
benjaoming Jul 20, 2017
db22bdd
Convert README.md to README.rst
benjaoming Jul 20, 2017
ebd37e7
Add badges
benjaoming Jul 20, 2017
4a8fc37
Merge pull request #5 from learningequality/modernize-arch
benjaoming Jul 20, 2017
0394339
Fix badge URLs
benjaoming Jul 20, 2017
b81fd21
Add some release notes and bump to 0.11dev
benjaoming Jul 27, 2017
4ae8c14
Remove ``encoding`` keyword arg
benjaoming Jul 27, 2017
9b96c9d
Remove no-op Linux kernel 2.x parser
benjaoming Jul 27, 2017
14940e1
Clean up class hierarchy, remove IfcfgParser (odd name)
benjaoming Jul 27, 2017
7a29b6b
Refactor tests so there's room to start implementing tests for mocked…
benjaoming Jul 28, 2017
a2dc891
[WIP] adding Windows stuff that isnt finished
benjaoming Jul 28, 2017
c5bea48
Revert coveragerc to parallel stuff
benjaoming Jul 28, 2017
c954342
Oops, remove wrong notifications
benjaoming Jul 29, 2017
5695479
First round of Windows tests and parsing, ipv4 + mac detection
benjaoming Jul 31, 2017
9c101e7
Fix coverage settings
benjaoming Aug 1, 2017
d104dd4
Python 2.7: Make everything Unicode
benjaoming Aug 1, 2017
75b02d0
Try removing source filter
benjaoming Aug 1, 2017
b860bdc
Use Nose's coverage plugin
benjaoming Aug 1, 2017
0d5a43c
Add test to ensure we fail on some illegal input, make more deliberat…
benjaoming Aug 1, 2017
7be79e5
Add a test that calls exec_cmd
benjaoming Aug 1, 2017
bcdf27b
Upgrade the parser, handling multiple IPv6 addresses
benjaoming Aug 1, 2017
927a7f5
Testing on Windows: platform.system() returns just 'Windows'
benjaoming Aug 1, 2017
0372c39
Makefile for doing releases etc
benjaoming Aug 1, 2017
479d173
Add support for devices without MAC or IPv6 (VMs)
benjaoming Aug 1, 2017
540fd8c
Bump to 0.11b2
benjaoming Aug 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .coveragerc

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pip-log.txt

# Unit test / coverage reports
.coverage
.coverage.*
.tox

#Translations
Expand All @@ -28,3 +29,4 @@ pip-log.txt
htmlcov
coverage_html_report
test.py
.venv
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: a11d9314b22d8f8c7556443875b731ef05965464
hooks:
- id: trailing-whitespace
- id: flake8
- id: check-yaml
- id: check-added-large-files
- id: debug-statements
- id: end-of-file-fixer
- repo: git://github.com/FalconSocial/pre-commit-python-sorter
sha: 5991d2aea26858d3c3538e0b4e09255b6b99413e
hooks:
- id: python-import-sorter
args:
- --silent-overwrite
- repo: git://github.com/pre-commit/mirrors-eslint
sha: v3.14.0
hooks:
- id: eslint
additional_dependencies: [ 'eslint', 'eslint-plugin-html', 'eslint-config-airbnb', 'eslint-plugin-import', 'eslint-plugin-jsx-a11y']
37 changes: 30 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
sudo: false
dist: trusty

env: PIP_DOWNLOAD_CACHE="pip_cache"

language: python
before_script: ./utils/bootstrap.sh
script: ./utils/run-tests.sh
python:
- "2.6"
- "2.7"
- "3.1"
- "3.2"

addons:
apt:
sources:
- deadsnakes
packages:
- python3.5
- python3.5-dev


# See tox.ini for env list
env:
- TOXENV=py27
- TOXENV=py34
- TOXENV=py35
- TOXENV=lint

install:
- pip install -U pip codecov tox

script:
- tox -e $TOXENV

after_success:
- codecov
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
clean: clean-build clean-pyc clean-test


clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/

lint: ## Check python code conventions
tox -e lint

test: ## Run automated test suite
nosetests

test-all: ## Run tests on all supported Python environments
tox

coverage: ## Generate test coverage report
coverage run --source src/ifcfg `which nosetests`
coverage report -m

release: dist ## Generate and upload release to PyPi
@echo ""
@echo "Release check list:"
@echo ""
@echo "1. Release notes?"
@echo "2. Did you do a signed commit and push to Github?"
@echo "3. Check that the .whl and .tar.gz dists work - e.g. that MANIFEST.in is updated."
@echo ""
@read -p "CTRL+C or ENTER" dummy
twine upload -s dist/*

dist: clean ## Generate wheels distribution
python setup.py bdist_wheel
python setup.py sdist
ls -l dist
80 changes: 0 additions & 80 deletions README.md

This file was deleted.

123 changes: 123 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
Python Ifconfig Wrapper for Unix/Linux/MacOSX
=============================================

.. image:: https://badge.fury.io/py/ifcfg.svg
:target: https://pypi.python.org/pypi/ifcfg/
.. image:: https://travis-ci.org/learningequality/python-ifcfg.svg
:target: https://travis-ci.org/learningequality/python-ifcfg
.. image:: http://codecov.io/github/learningequality/python-ifcfg/coverage.svg?branch=master
:target: http://codecov.io/github/learningequality/python-ifcfg?branch=master

Ifcfg is a cross-platform (\*nix) library for parsing 'ifconfig' output
in Python. It is useful for pulling information such as IP, Netmask, MAC
Address, Hostname, etc.

Some Limitations:

- Targeted for Unix-like operating systems including Linux and Mac OSX
- Relies on parsing ``ifconfig`` or ``ip address`` output

Usage
-----

::

import ifcfg
import json

for interface in ifcfg.interfaces:
# do something with interface
print interface['device']
print interface['inet']
print interface['inet6']
print interface['netmask']
print interface['broadcast']

default = ifcfg.default_interface()

The output of 'ifcfg.interfaces' dumped to JSON looks something like the
following:

::

$ python test.py | python -mjson.tool
{
"eth0": {
"broadcast": "172.16.217.255",
"ether": "00:0c:29:0c:da:5d",
"flags": "4163<up,broadcast,running,multicast> ",
"hostname": "derks-vm.local",
"inet": "172.16.217.10",
"inet6": "fe80::20c:29ff:fe0c:da5d",
"mtu": "1500",
"name": "eth0",
"netmask": "255.255.255.0",
"prefixlen": "64",
"scopeid": "0x20<link>"
},
"lo": {
"ether": null,
"flags": "73<up,loopback,running> ",
"hostname": "localhost",
"inet": "127.0.0.1",
"inet6": "::1",
"mtu": "16436",
"name": "lo",
"netmask": "255.0.0.0",
"prefixlen": "128",
"scopeid": "0x10<host>"
},
"virbr0": {
"broadcast": "192.168.122.255",
"ether": "52:54:00:5b:70:0d",
"flags": "4099<up,broadcast,multicast> ",
"hostname": "derks-vm.local",
"inet": "192.168.122.1",
"inet6": null,
"mtu": "1500",
"name": "virbr0",
"netmask": "255.255.255.0",
}
}


Release notes
-------------

0.11 (unreleased)
_________________

This release seeks to clean up the codebase (sparingly!) and introduce
Windows compatibility.

* Removing ill-defined ``encoding`` keyword arg from ``ifcfg.get_parser``
* Removed no-op Linux Kernel 2.x parsing and ``kernel`` keyword arg
* Removed class ``ifcfg.IfcfgParser``, use ``UnixParser`` instead
* All strings are UTF-8, also in Py 2.7
* Only cross-platform features are now guaranteed to be in the result set:
``['inet', 'ether', 'inet6', 'netmask']``
* IPv6 addresses are now stored in a list.
* Removed prefixlen, as it should be added to one IPv6 address, not the
interface


0.10.1
____

* Fixed encoding issues, preventing ``default_interface`` to be detected


0.10
____

* Support for Unix systems w/o ``ifconfig``, for instance newer Ubuntu/Debian
* Refactored to use ``src/`` hierarchy



License
-------

The Ifcfg library is Open Source and is distributed under the BSD
License (three clause). Please see the LICENSE file included with this
software.
Loading