diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 8bf8e92..0000000 --- a/.coveragerc +++ /dev/null @@ -1,6 +0,0 @@ -[run] -omit = - /tests - /*/__init__.py - /setup.py - *info.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml index db95827..6e4aa79 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,3 +11,9 @@ updates: interval: "monthly" commit-message: prefix: "[deps] " + - package-ecosystem: "github-actions" # Check for GitHub Actions updates + directory: "/" + schedule: + interval: "monthly" # Check for updates weekly + commit-message: + prefix: "[ci] " diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ffbd64..88ddf1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: build: name: Python==${{ matrix.python-version }} | ${{ matrix.django-version }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -29,41 +29,39 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + **/requirements*.txt - - name: Upgrade python system packages - run: pip install -U pip wheel - - - name: Install test dependencies - run: pip install -r requirements-test.txt - - - name: Install netdiff - run: pip install -e . + - name: Install Dependencies + id: deps + run: | + pip install -U pip wheel setuptools + pip install -U -r requirements-test.txt + pip install -U -e . + pip install --no-cache-dir --no-deps -U "openwisp-utils[qa] @ https://github.com/openwisp/openwisp-utils/tarball/master" - name: QA checks run: ./run-qa-checks - name: Tests - run: coverage run -a --source=netdiff runtests.py + if: ${{ !cancelled() && steps.deps.conclusion == 'success' }} + run: coverage run runtests.py - name: Upload Coverage - run: coveralls --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: python-${{ matrix.python-version }} - COVERALLS_PARALLEL: true + if: ${{ success() }} + uses: coverallsapp/github-action@v2 + with: + format: cobertura + flag-name: python-${{ matrix.env.env }} + github-token: ${{ secrets.GITHUB_TOKEN }} coveralls: - name: Finish Coveralls needs: build runs-on: ubuntu-latest - container: python:3-slim steps: - - name: Finished - run: | - pip3 install --upgrade coveralls - coveralls --finish --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 diff --git a/CHANGES.rst b/CHANGES.rst index 060db70..cd1b4cb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -15,10 +15,10 @@ Version 1.0.0 [28-04-2022] Version 0.9.0 [28-07-2020] -------------------------- -- **Backward incompatible change for OpenVPN Parser**: - switched to use common name as netjson ID to avoid duplicate nodes when - multiple nodes are behind the same public IP, for more information - see `Specialized features: OpenVPN `_ +- **Backward incompatible change for OpenVPN Parser**: switched to use + common name as netjson ID to avoid duplicate nodes when multiple nodes + are behind the same public IP, for more information see `Specialized + features: OpenVPN `_ Version 0.8.0 [28-06-2020] -------------------------- @@ -27,13 +27,12 @@ Version 0.8.0 [28-06-2020] be missed if the OpenVPN nodes had same IP but different ports - Feature: detect changes in nodes and links - Change: Added/remove/changed nodes/links are now sorted -- Change: Unspecified fields like node's label and link's ``cost_text`` are now always - shown as empty string if they are not specified +- Change: Unspecified fields like node's label and link's ``cost_text`` + are now always shown as empty string if they are not specified - Change: Parse ``cost_text`` field from links -- **Backward incompatible change**: the output of ``diff`` in this release differs - slightly from the previous versions. - Applications using previous netdiff versions will likely need minor adjustments - to their code +- **Backward incompatible change**: the output of ``diff`` in this release + differs slightly from the previous versions. Applications using previous + netdiff versions will likely need minor adjustments to their code - Documentation Improvements - Added support for openwisp-utils~=0.5.0 @@ -56,114 +55,151 @@ Version 0.6.0 [27-12-2017] [openvpn] Convert node properties to integer - `6b72dab `_: [openvpn] Avoid failing if data is empty -- `#56 `_: - Updated networkx to 2.0 +- `#56 `_: Updated networkx + to 2.0 Version 0.5.2 [26-12-2017] -------------------------- -- `#55 `_: - Added a label in OpenvpnParser output -- `#52 `_: - Added a label in NetjsonParser output -- `#49 `_: - Added support to TAP mode in OpenVPN parser +- `#55 `_: Added a label in + OpenvpnParser output +- `#52 `_: Added a label in + NetjsonParser output +- `#49 `_: Added support to + TAP mode in OpenVPN parser Version 0.5.1 [29-09-2017] -------------------------- -- `#47 `_: - Added OpenVPN parser +- `#47 `_: Added OpenVPN + parser Version 0.5.0 [30-08-2017] -------------------------- -- `#40 `_: - implemented stricter input (**backward incompatible**) +- `#40 `_: implemented + stricter input (**backward incompatible**) Version 0.4.8 [30-08-2017] -------------------------- -- pinned precise supported versions of dependencies to avoid incompatibilities +- pinned precise supported versions of dependencies to avoid + incompatibilities Version 0.4.7 [04-01-2016] -------------------------- -- `c79b745 `_: fixed return value of ``_get_primary_address()`` in ``BatmanParser`` +- `c79b745 `_: fixed + return value of ``_get_primary_address()`` in ``BatmanParser`` Version 0.4.6 [27-12-2015] -------------------------- -- `#36 `_: fixed wrong diff when same nodes but different links +- `#36 `_: fixed wrong diff + when same nodes but different links Version 0.4.5 [28-09-2015] -------------------------- -- `#34 `_: show ``local_addresses`` in NetJSON output (``OlsrParser``, ``BatmanParser`` and ``NetJsonParser``) -- `#29 `_: support additional properties in NetJSON output -- `#32 `_: mock telnet requests in tests -- `63a5e8a `_: added ``"Unrecognized format"`` message in ``ParserError`` exceptions -- `9ed48a4 `_: added arbitrary metric value (average of tx and rx) in ``Bmx6Parser`` +- `#34 `_: show + ``local_addresses`` in NetJSON output (``OlsrParser``, ``BatmanParser`` + and ``NetJsonParser``) +- `#29 `_: support + additional properties in NetJSON output +- `#32 `_: mock telnet + requests in tests +- `63a5e8a `_: added + ``"Unrecognized format"`` message in ``ParserError`` exceptions +- `9ed48a4 `_: added + arbitrary metric value (average of tx and rx) in ``Bmx6Parser`` Version 0.4.4 [06-09-2015] -------------------------- -- `#31 `_: mocked HTTP requests in tests -- `#28 `_: replaced weight with cost in all NetJSON occurrences +- `#31 `_: mocked HTTP + requests in tests +- `#28 `_: replaced weight + with cost in all NetJSON occurrences Version 0.4.3 [02-07-2015] -------------------------- -- `#27 `_: added support for txtinfo format to ``BatmanParser`` -- `ab9c40 `_, `9ac89a `_: minor optimizations and simplifications in ``BatmanParser`` -- `990a30 `_: minor optimization in ``Bmx6Parser`` -- `64f8f44 `_: the parse() method of each parser now must return a networkx.Graph instance instead of storing it +- `#27 `_: added support + for txtinfo format to ``BatmanParser`` +- `ab9c40 `_, `9ac89a + `_: minor + optimizations and simplifications in ``BatmanParser`` +- `990a30 `_: minor + optimization in ``Bmx6Parser`` +- `64f8f44 `_: the + parse() method of each parser now must return a networkx.Graph instance + instead of storing it Version 0.4.2 [27-06-2015] -------------------------- -- `deea34 `_: skip links with infinite cost in ``OlsrParser`` +- `deea34 `_: skip + links with infinite cost in ``OlsrParser`` Version 0.4.1 [26-06-2015] -------------------------- -- `#13 `_: added support for OLSR 0.6.x txtinfo plugin -- `e94e91 `_: updated default "version" attribute of ``OlsrParser`` +- `#13 `_: added support + for OLSR 0.6.x txtinfo plugin +- `e94e91 `_: updated + default "version" attribute of ``OlsrParser`` Version 0.4 [14-06-2015] ------------------------ -- `#21 `_: **breaking change** made ``diff`` output consistent with NetJSON ``NetworkGraph`` -- `#24 `_: add "changed" section to ``diff`` to show changes in weight -- `a6a161a `_: ``diff`` now returns an OrderedDict +- `#21 `_: **breaking + change** made ``diff`` output consistent with NetJSON ``NetworkGraph`` +- `#24 `_: add "changed" + section to ``diff`` to show changes in weight +- `a6a161a `_: + ``diff`` now returns an OrderedDict Version 0.3.2 [03-06-2015] -------------------------- -- `#26 `_: renamed exceptions with "NetParser" prefix -- `#25 `_: raise Exception if topology file/URL not reachable -- `53e02cc `_: flagged ``to_python`` of ``BaseParser`` as public -- `48d2927 `_: refactored exceptions, added explaination in README +- `#26 `_: renamed + exceptions with "NetParser" prefix +- `#25 `_: raise Exception + if topology file/URL not reachable +- `53e02cc `_: flagged + ``to_python`` of ``BaseParser`` as public +- `48d2927 `_: + refactored exceptions, added explaination in README Version 0.3.1 [22-05-2015] -------------------------- -- `c91e4e `_: corrected weight in ``OlsrParser`` -- `#22 `_: added subtraction operator as a shortcut to diff function -- `be9f476 `_: corrected ``MANIFEST.in`` to fix egg builds +- `c91e4e + `_: + corrected weight in ``OlsrParser`` +- `#22 `_: added subtraction + operator as a shortcut to diff function +- `be9f476 `_: + corrected ``MANIFEST.in`` to fix egg builds Version 0.3 [15-05-2015] ------------------------ - `#18 `_: added CNML parser -- `#17 `_: added BMX6 (b6m tool) parser -- `#16 `_: added ``NetParserJsonException`` which is raised if no JSON object can be decoded in ``_to_python`` -- `#14 `_: replaced ``startswith`` string method with ``urlparse`` module for URL scheme recognition +- `#17 `_: added BMX6 (b6m + tool) parser +- `#16 `_: added + ``NetParserJsonException`` which is raised if no JSON object can be + decoded in ``_to_python`` +- `#14 `_: replaced + ``startswith`` string method with ``urlparse`` module for URL scheme + recognition Version 0.2 [08-05-2015] ------------------------ -- `#12 `_: Added support for telnet urls in ``BaseParser`` +- `#12 `_: Added support for + telnet urls in ``BaseParser`` Version 0.1 [02-05-2015] ------------------------ diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1b9ac40..58b1971 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,5 +1,7 @@ Contributing ============ -Thanks for your interest! We love contributions, so please feel free to fix bugs, improve things, provide documentation. Just `follow the -guidelines `_ and submit a PR. +Thanks for your interest! We love contributions, so please feel free to +fix bugs, improve things, provide documentation. Just `follow the +guidelines `_ and submit a +PR. diff --git a/README.rst b/README.rst index 6d5d4ab..b7e3094 100644 --- a/README.rst +++ b/README.rst @@ -2,58 +2,61 @@ netdiff ======= .. image:: https://github.com/openwisp/netdiff/workflows/OpenWISP%20CI%20Build/badge.svg?branch=master - :target: https://github.com/openwisp/netdiff/actions?query=workflow%3A%22OpenWISP+CI+Build%22 - :alt: CI build status + :target: https://github.com/openwisp/netdiff/actions?query=workflow%3A%22OpenWISP+CI+Build%22 + :alt: CI build status .. image:: https://coveralls.io/repos/openwisp/netdiff/badge.svg - :target: https://coveralls.io/r/openwisp/netdiff + :target: https://coveralls.io/r/openwisp/netdiff .. image:: https://img.shields.io/librariesio/release/github/openwisp/netdiff - :target: https://libraries.io/github/openwisp/netdiff#repository_dependencies - :alt: Dependency monitoring + :target: https://libraries.io/github/openwisp/netdiff#repository_dependencies + :alt: Dependency monitoring .. image:: https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square - :target: https://gitter.im/openwisp/general + :target: https://gitter.im/openwisp/general .. image:: https://badge.fury.io/py/netdiff.svg - :target: http://badge.fury.io/py/netdiff + :target: http://badge.fury.io/py/netdiff .. image:: https://pepy.tech/badge/netdiff - :target: https://pepy.tech/project/netdiff - :alt: downloads + :target: https://pepy.tech/project/netdiff + :alt: downloads .. image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://pypi.org/project/black/ - :alt: code style: black + :target: https://pypi.org/project/black/ + :alt: code style: black ------------- +---- Netdiff is a simple abstraction layer for parsing network topology data of -open source dynamic routing protocols or any other networking software which -has knowledge about the topology of a network. +open source dynamic routing protocols or any other networking software +which has knowledge about the topology of a network. -Its goal is to allow applications like -`openwisp-network-topology `_ -to collect, visualize and monitor network topology data without having to deal -with the details of each networking software from which the data is retrieved. +Its goal is to allow applications like `openwisp-network-topology +`_ to collect, +visualize and monitor network topology data without having to deal with +the details of each networking software from which the data is retrieved. **Features**: -* `parse different formats `_ -* `detect changes in two topologies `_ -* `return consistent NetJSON output `_ -* uses the popular `networkx `_ library under the hood +- `parse different formats `_ +- `detect changes in two topologies + `_ +- `return consistent NetJSON output + `_ +- uses the popular `networkx `_ library under + the hood .. image:: https://raw.githubusercontent.com/openwisp/openwisp2-docs/master/assets/design/openwisp-logo-black.svg - :target: http://openwisp.org + :target: http://openwisp.org ------------- +---- .. contents:: **Table of Contents**: - :backlinks: none - :depth: 3 + :backlinks: none + :depth: 3 ------------- +---- Install stable version from pypi -------------------------------- @@ -97,8 +100,8 @@ Calculate diff of an OLSR 0.6.x topology: from netdiff import OlsrParser from netdiff import diff - old = OlsrParser(file='./stored-olsr.json') - new = OlsrParser(url='http://127.0.0.1:9090') + old = OlsrParser(file="./stored-olsr.json") + new = OlsrParser(url="http://127.0.0.1:9090") diff(old, new) In alternative, you may also use the subtraction operator: @@ -108,34 +111,32 @@ In alternative, you may also use the subtraction operator: from netdiff import OlsrParser from netdiff import diff - old = OlsrParser(file='./stored-olsr.json') - new = OlsrParser(url='http://127.0.0.1:9090') + old = OlsrParser(file="./stored-olsr.json") + new = OlsrParser(url="http://127.0.0.1:9090") old - new The output will be an ordered dictionary with three keys: -* added -* removed -* changed +- added +- removed +- changed -Each key will contain a dict compatible with the `NetJSON NetworkGraph`_ format -representing respectively: +Each key will contain a dict compatible with the `NetJSON NetworkGraph`_ +format representing respectively: -* the nodes and links that have been added to the topology -* the nodes and links that have been removed from the topology -* the nodes and links that are present in both topologies but their attributes have changed +- the nodes and links that have been added to the topology +- the nodes and links that have been removed from the topology +- the nodes and links that are present in both topologies but their + attributes have changed If no changes are present, keys will contain ``None``. -So if between ``old`` and ``new`` there are no changes, the result will be: +So if between ``old`` and ``new`` there are no changes, the result will +be: .. code-block:: python - { - "added": None - "removed": None, - "changed": None - } + {"added": None, "removed": None, "changed": None} While if there are changes, the result will look like: @@ -153,33 +154,31 @@ While if there are changes, the result will look like: "id": "10.150.0.7", "label": "Node A", "local_addresses": [], - "properties": {} + "properties": {}, }, { "id": "10.150.0.6", "label": "Node B", "local_addresses": ["10.56.2.1"], - "properties": { - "hostname": "nodeb.lan" - } - } + "properties": {"hostname": "nodeb.lan"}, + }, ], "links": [ { "source": "10.150.0.3", "target": "10.150.0.7", "cost": 1.50390625, - "cost_text", "", - "properties": {} + "cost_text": "", + "properties": {}, }, { "source": "10.150.0.3", "target": "10.150.0.6", - "cost": 1.0 - "cost_text", "", - "properties": {} - } - ] + "cost": 1.0, + "cost_text": "", + "properties": {}, + }, + ], }, "removed": { "type": "NetworkGraph", @@ -192,18 +191,18 @@ While if there are changes, the result will look like: "id": "10.150.0.8", "label": "Node C", "local_addresses": [], - "properties": {} + "properties": {}, } ], "links": [ { "source": "10.150.0.7", "target": "10.150.0.8", - "cost": 1.0 - "cost_text", "", - "properties": {} + "cost": 1.0, + "cost_text": "", + "properties": {}, } - ] + ], }, "changed": { "type": "NetworkGraph", @@ -216,51 +215,65 @@ While if there are changes, the result will look like: { "source": "10.150.0.3", "target": "10.150.0.2", - "cost": 1.0 - "cost_text", "", - "properties": {} + "cost": 1.0, + "cost_text": "", + "properties": {}, } - ] - } + ], + }, } Parsers ------- -Parsers are classes that extend ``netdiff.base.BaseParser`` and implement a ``parse`` method -which is in charge of converting a python data structure into ``networkx.Graph`` object and return the result. +Parsers are classes that extend ``netdiff.base.BaseParser`` and implement +a ``parse`` method which is in charge of converting a python data +structure into ``networkx.Graph`` object and return the result. -Parsers also have a ``json`` method which returns valid `NetJSON output `_. +Parsers also have a ``json`` method which returns valid `NetJSON output +`_. The available parsers are: -* ``netdiff.OlsrParser``: parser for the `olsrd jsoninfo plugin `_ - or the older `txtinfo plugin `_ -* ``netdiff.BatmanParser``: parser for the `batman-advanced alfred tool `_ - (supports also the legacy txtinfo format inherited from olsrd) -* ``netdiff.Bmx6Parser``: parser for the BMX6 `b6m tool `_ -* ``netdiff.CnmlParser``: parser for `CNML 0.1 `_ -* ``netdiff.NetJsonParser``: parser for the `NetJSON NetworkGraph`_ format -* ``netdiff.OpenvpnParser``: parser for the `OpenVPN status file `_ -* ``netdiff.WireguardParser``: parser for the Wireguard VPN (the command to use is ``wg show all dump``) -* ``netdiff.ZeroTierParser``: parser for ZeroTier VPN (the command to use is ``zerotier-cli peers -j`` or - access the peers information through the `ZeroTier Service API `_) +- ``netdiff.OlsrParser``: parser for the `olsrd jsoninfo plugin + `_ or the older `txtinfo plugin + `_ +- ``netdiff.BatmanParser``: parser for the `batman-advanced alfred tool + `_ (supports + also the legacy txtinfo format inherited from olsrd) +- ``netdiff.Bmx6Parser``: parser for the BMX6 `b6m tool + `_ +- ``netdiff.CnmlParser``: parser for `CNML 0.1 + `_ +- ``netdiff.NetJsonParser``: parser for the `NetJSON NetworkGraph`_ format +- ``netdiff.OpenvpnParser``: parser for the `OpenVPN status file + `_ +- ``netdiff.WireguardParser``: parser for the Wireguard VPN (the command + to use is ``wg show all dump``) +- ``netdiff.ZeroTierParser``: parser for ZeroTier VPN (the command to use + is ``zerotier-cli peers -j`` or access the peers information through the + `ZeroTier Service API + `_) Initialization arguments ~~~~~~~~~~~~~~~~~~~~~~~~ -Data can be supplied in 3 different ways, in the following order of precedence: +Data can be supplied in 3 different ways, in the following order of +precedence: -* ``data``: ``dict`` or ``str`` representing the topology/graph -* ``url``: URL to fetch data from -* ``file``: file path to retrieve data from +- ``data``: ``dict`` or ``str`` representing the topology/graph +- ``url``: URL to fetch data from +- ``file``: file path to retrieve data from Other available arguments: -* **timeout**: integer representing timeout in seconds for HTTP or telnet requests, defaults to ``None`` -* **verify**: boolean indicating to the `request library whether to do SSL certificate - verification or not `_ -* **directed**: boolean that enables the use of a directed graph (``networkx.DiGraph``), defaults to ``False`` +- **timeout**: integer representing timeout in seconds for HTTP or telnet + requests, defaults to ``None`` +- **verify**: boolean indicating to the `request library whether to do SSL + certificate verification or not + `_ +- **directed**: boolean that enables the use of a directed graph + (``networkx.DiGraph``), defaults to ``False`` Initialization examples ~~~~~~~~~~~~~~~~~~~~~~~ @@ -270,14 +283,16 @@ Local file example: .. code-block:: python from netdiff import BatmanParser - BatmanParser(file='./my-stored-topology.json') + + BatmanParser(file="./my-stored-topology.json") HTTP example: .. code-block:: python from netdiff import NetJsonParser - url = 'https://raw.githubusercontent.com/interop-dev/netjson/master/examples/network-graph.json' + + url = "https://raw.githubusercontent.com/interop-dev/netjson/master/examples/network-graph.json" NetJsonParser(url=url) Telnet example with ``timeout``: @@ -285,14 +300,18 @@ Telnet example with ``timeout``: .. code-block:: python from netdiff import OlsrParser - OlsrParser(url='telnet://127.0.1', timeout=5) + + OlsrParser(url="telnet://127.0.1", timeout=5) HTTPS example with self-signed SSL certificate using ``verify=False``: .. code-block:: python from netdiff import NetJsonParser - OlsrParser(url='https://myserver.mydomain.com/topology.json', verify=False) + + OlsrParser( + url="https://myserver.mydomain.com/topology.json", verify=False + ) NetJSON output -------------- @@ -303,7 +322,7 @@ Netdiff parsers can return a valid `NetJSON NetworkGraph`_ object: from netdiff import OlsrParser - olsr = OlsrParser(url='telnet://127.0.0.1:9090') + olsr = OlsrParser(url="telnet://127.0.0.1:9090") # will return a dict olsr.json(dict=True) @@ -349,7 +368,8 @@ Output: Exceptions ---------- -All the exceptions are subclasses of ``netdiff.exceptions.NetdiffException``. +All the exceptions are subclasses of +``netdiff.exceptions.NetdiffException``. ConversionException ~~~~~~~~~~~~~~~~~~~ @@ -358,9 +378,11 @@ ConversionException Raised when netdiff can't recognize the format passed to the parser. -Not necessarily an error, should be caught and managed in order to support additional formats. +Not necessarily an error, should be caught and managed in order to support +additional formats. -The data which was retrieved from network/storage can be accessed via the "data" attribute, eg: +The data which was retrieved from network/storage can be accessed via the +"data" attribute, eg: .. code-block:: python @@ -382,16 +404,17 @@ NetJsonError ``netdiff.exceptions.NetJsonError`` -Raised when the ``json`` method of ``netdiff.parsers.BaseParser`` does not have enough data -to be compliant with the `NetJSON NetworkGraph`_ specification. +Raised when the ``json`` method of ``netdiff.parsers.BaseParser`` does not +have enough data to be compliant with the `NetJSON NetworkGraph`_ +specification. TopologyRetrievalError ~~~~~~~~~~~~~~~~~~~~~~ ``netdiff.exceptions.TopologyRetrievalError`` -Raised when it is not possible to retrieve the topology data -(eg: the URL might be temporary unreachable). +Raised when it is not possible to retrieve the topology data (eg: the URL +might be temporary unreachable). Specialized features -------------------- @@ -401,18 +424,19 @@ OpenVPN By default, the OpenVPN parser uses the common name to identify a client, this was chosen because if the public IP address is used, the same client -will not be recognized if it connects with a different IP address -(very probable since many ISPs use dynamic public IP addresses). +will not be recognized if it connects with a different IP address (very +probable since many ISPs use dynamic public IP addresses). -This does not work when the vpn server configuration allows different clients -to use the same common name (which is generally not recommended anyway). +This does not work when the vpn server configuration allows different +clients to use the same common name (which is generally not recommended +anyway). -If you need to support legacy systems which are configured with the OpenVPN -``duplicate-cn`` feature enabled, you can pass ``duplicate_cn=True`` during -the initialization of ``OpenvpnParser``. -This will change the behavior of the parser so that each client is identified -by their common name and IP address (and additionally the port used if there -are multiple clients with same common name and IP). +If you need to support legacy systems which are configured with the +OpenVPN ``duplicate-cn`` feature enabled, you can pass +``duplicate_cn=True`` during the initialization of ``OpenvpnParser``. This +will change the behavior of the parser so that each client is identified +by their common name and IP address (and additionally the port used if +there are multiple clients with same common name and IP). Known Issues ------------ @@ -420,10 +444,14 @@ Known Issues ConnectionError: BadStatusLine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If you get a similar error when performing a request to the `jsoninfo plugin `_ of -`olsrd `_ (version 0.6 to 0.9) chances are high that http headers are disabled. +If you get a similar error when performing a request to the `jsoninfo +plugin `_ of `olsrd +`_ (version 0.6 to 0.9) chances are high that http +headers are disabled. + +To fix it turn on http headers in your olsrd configuration file, eg: -To fix it turn on http headers in your olsrd configuration file, eg:: +:: LoadPlugin "olsrd_jsoninfo.so.0.0" { @@ -456,7 +484,8 @@ Run tests with: ./runtests.py ./run-qa-checks -Alternatively, you can use the ``nose2`` command (which has a ton of available options): +Alternatively, you can use the ``nose2`` command (which has a ton of +available options): .. code-block:: shell @@ -475,7 +504,8 @@ See test coverage with: Contributing ------------ -Please refer to the `OpenWISP contributing guidelines `_. +Please refer to the `OpenWISP contributing guidelines +`_. Support ------- @@ -485,11 +515,12 @@ See `OpenWISP Support Channels `_. Changelog --------- -See `CHANGES `_. +See `CHANGES +`_. License ------- See `LICENSE `_. -.. _`NetJSON NetworkGraph`: http://netjson.org/rfc.html#rfc.section.4 +.. _netjson networkgraph: http://netjson.org/rfc.html#rfc.section.4 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3ae63aa --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[tool.isort] +known_first_party = ["netdiff"] +default_section = "THIRDPARTY" +line_length = 88 +multi_line_output = 3 +use_parentheses = true +include_trailing_comma = true +force_grid_wrap = 0 + +[tool.coverage.run] +parallel = true +omit = [ + "**/test*", + "tests", + "**/__init__.py", + "setup.py", + "**info.py", +] +source = ["netdiff"] + +[tool.docstrfmt] +extend_exclude = ["**/*.py"] diff --git a/setup.cfg b/setup.cfg index a330095..7e76cd2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,10 +4,3 @@ universal=1 [flake8] exclude = setup.py max-line-length = 110 - -[isort] -line_length = 110 -skip = setup.py -default_section = THIRDPARTY -known_first_party = netdiff -not_skip = __init__.py diff --git a/setup.py b/setup.py index 8452c23..80d39dd 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys -from setuptools import setup, find_packages + +from setuptools import find_packages, setup # avoid networkx ImportError sys.path.insert(0, 'netdiff')