log entry 2013-08-17

iptables-optimizer version 0.9.8

Version 0.9.8 is out. git-buildpackage is a wonderful tool.

After some tries and errors with git-buildpackage it works quite well for me. A lot of things were changed since the last post, which mentioned 0.9.1

The tests, especially those run by python3, were suspected to fool me. On looking somehow deeper, I found that it might be a good idea to use 2to3 and then let nosetests3 do the rest. So it was easy to modify tox.ini:

# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py26, py27, py32, pep8

[testenv]
commands = /usr/local/bin/nosetests

[testenv:py26]
basepython =
    python2.6
commands =
    python setup.py clean
    python setup.py build
    /usr/local/bin/nosetests -v iptables_optimizer_tests.py

[testenv:py27]
basepython =
    python2.7
commands =
    python setup.py clean
    python setup.py build
    /usr/local/bin/nosetests -v iptables_optimizer_tests.py

[testenv:py32]
basepython =
    python3.2
commands =
    /usr/bin/2to3 --add-suffix='3' -n -w ./iptables_optimizer.py
    /usr/bin/python3.2 setup.py clean
    /usr/bin/python3.2 setup.py build
    /usr/bin/nosetests3 -v iptables_optimizer_tests.py

[testenv:pep8]
commands = /usr/local/bin/pep8 --show-pep8 --show-source iptables_optimizer.py

Now the tests work fine with python3:

hans@jha:~/gh/opti$ nosetests3  -v
Chain_Test: create a chainobject ... ok
Chain_Test: make partitions from no rules ... ok
Chain_Test: make partitions from one rule a ... ok
Chain_Test: make partitions from one rule d ... ok
Chain_Test: make partitions from one rule r ... ok
Chain_Test: make partitions from one rule l ... ok
Chain_Test: make partitions from two rules aa ... ok
Chain_Test: make partitions from two rules ad ... ok
Chain_Test: make partitions from five rules adaaa ... ok
Chain_Test: optimize an empty chainobject ... ok
Chain_Test: optimize three rules aaa ... ok
Chain_Test: optimize three rules aar ... ok
Chain_Test: optimize five rules aalaa ... ok
Filter_Test: non existant input-file ... ok
Filter_Test: read reference-input ... ok
Filter_Test: optimize, check 30 moves and partitions ... ok
Filter_Test: check output for reference-input ... ok

----------------------------------------------------------------------
Ran 17 tests in 0.037s

OK
hans@jha:~/gh/opti$

Invoking tox is simply done by issuing tox on the command line, it is rather verbose. Therefore I only show the last few lines of output containing the results.

...
pep8 inst-nodeps: /home/hans/deb/opti/.tox/dist/iptables-optimizer-0.9.8.zip
pep8 runtests: commands[0]
___________________________________ summary ____________________________________
  py26: commands succeeded
  py27: commands succeeded
  py32: commands succeeded
  pep8: commands succeeded
  congratulations :)
hans@jha:~/gh/opti$

Another interesting value is the rating of pylint:

Your code has been rated at 9.55/10*

I'm happy with it.

Of course all the print statements and some error handling had to be rewritten for python3 compatibility, fortunately python2.6 and 2.7 are able to understand the modified syntax.

Some other changes were done to satisfy debian needs:

  1. reference-input and reference-output moved to /var/run/
  2. auto-apply moved to /var/cache/iptables-optimizer
  3. Because the debian/prerm didn't remove the files for a dpkg --purge action, Tim sent a patch which moves it to debian/postrm. Thank you very much, Tim.

Now it seems to work like wanted from the beginning, only a small thing is left: Remove the deprecated dh_pysupport from then rules and get dh_python2 or dh_python3 instead.

Last week I found another starred repo named python-iptables from Juliano Martinez, building a pythonic interface to libiptc. Becoming familiar with it, external wrapper with iptables-save and -restore might be obsoleted, and the ugly shell wrapper as well. Seems to be interesting, only some time is needed.

So there is still something left to be done...

Have fun!

social