Implementation

(Contrôle qualité)

Documentation

This keepcool documentation is embedded into the project:

# apt-get install python-sphinx
$ cd doc
$ make html

It is also available as PDF format:

$ make latex
$ cd build/latex
$ make
$ xpdf keepcool.pdf

Note: images should be re-compilated manually, please see doc/README.

Coding

We decided to follow the PEP8 coding standard:

# apt-get install pep8 pylint
$ pep8 keepcool.py
$ pylint keepcool.py

Environment

We should had use python3 for this new project but we prefer to use the default python version of Debian Stable.

Even if still not needed, we plan to use virtualenv in order to work on many projects that may have different requirements on module’s versions:

# apt-get install python-pip virtualenv
$ virtualenv dev
$ . dev/bin/activate
(dev) $
Troubles comes when python’s modules when versions available from Debian stable are too old and cannot be find anymore using pip. As it is the case for this project (python-git 2.1 on Debian vs versions from 3.1 from pip).
Because we don’t need to get more up-to-date modules, we decided not to use virtualenv for this project.

Project structure

As I’m a newbie in writing Python project from scratch, I’m looking for an “hello world” project, like ones we can get for debian packaging:

$ apt-get source hello

I find this one but it is oriented for django:

$ git clone https://git.entrouvert.org/bidon.git/

I find this other one which is pip‘s package oriented.

$ pip download hello-world-py
$ find .
./hello
./hello/__main__.py
./hello/__init__.py
./hello/Hello.py
./setup.py
./PKG-INFO

As I do not find anything convincing, I decided to use a single module file (needed for unit tests) that provide a main entry point.

Unit tests

I only use a signle file using the unittest framework.

$ ./test_keepcool.py
Ran 28 tests in 0.079s
OK

Code coverage

Here is the test coverage report:

# apt-get install python-coverage
$ ./coverage.sh
keepcool.py       ... 93%

Deploy infrastructure

Maybe a simple git clone query should be sufficient here:

$ mkdir repo
$ cd repo
$ git clone https://git.entrouvert.org/passerelle.git

However, we prefer to use ansible to clone and update the git repositories, as it may be useful for further operations.

# apt-get install ansible
$ ansible-doc git
$ ansible.sh

This ansible playbook connect localy the localhost using ssh, and it needs the current user il allow to connect without password:

$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Note: we could also use a more recent version of ansible (but not needed here).

$ pip install ansible>2.4.0