I know that ufw is written in python. Is it possible to use ufw as an api via python?
Sure, the ufw
executable is just a thin wrapper around a python package with the same name. I'm not aware of any documentation, but you can just poke around the source and have a look how everything works. Find the ufw
script location using which ufw
and the package location by starting the python interpreter, importing the ufw
module and asking it for its import path:
simon@mymachine:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ufw
>>> ufw.__file__
'/usr/lib/python2.6/dist-packages/ufw/__init__.pyc'
>>>