SWIG and functions with error codes and strerror

SWIG is a wrapper generator that is able to connect compiled libraries to a bunch of scripting languages. The process is mostly automatic, but to tackle some corner cases, you have to help the generator do the right thing. In my library, all functions would return an integer, which is an error code. A special function, following the same behavior as strerror_r, can be used to retrieve the meaning of a special error code. This is a pretty usual mechanism for C code. But that’s not the way scripting languages work. In their world, functions are rather supposed to raise exceptions.

Continue reading

Matplotlib: draw between subplots

Last week, I was preparing a data analysis report using Jupyter, Pandas and Matplotlib (to only quote a few bricks of this wonderful framework). One of the figures had two subplots, the second being an enlargement of a region of the first. To make it obvious, and at the same time show the old MATLAB Fanclub how so 90 they were, I decided to put an arrow from the first to the second subplot.

Matplotlib figure showing two subplot with an arrow spanning over both

Alas, from this simple idea started a three hours long research on the Internet, many trials and errors, even a bunch of crashes, and I was close to surrender against the technology of the last century… No way!

Continue reading
PyroPlayer Post Banner
Video

Introducing PyroPlayer

I love fireworks. At the crossing between science and art, beauty and power… So when last year, we were proposed my friend Adrien and I to develop a fireworks launch system, I immediately got very enthusiastic about the idea. And not only for the finality, but also because it was the perfect project to deploy the technologies we love.

Together with Adrien, we reviewed a panel of technologies before making our decision. We wanted to be able to prototype something rapidly, we had only 3 months before the first show. Boxes are built on top of Arduinos and XBee modules together with a special power cape we developed. Extensible, plug-and-play, and reusable. On the software side, we also had the constraint to be cross-platform. And to glue bricks together in a quick and clean way, what other language than Python?

Continue reading

Deploying Trac with Nginx and Gunicorn

I very recently re-deployed the Trac application on my server. The first time I did this, I used the included tracd server, but I had a very hard time configuring it on a non-root path with Nginx. So I decided to use Gunicorn, which is also reported to give better performance (is it true? I did not test).

The configuration is a front-end server running Nginx coupled with a back-end server running Gunicorn + Trac and the database which will be PostgreSQL. Static files will be deported at the end to the front-end server for performance. I will not go too much into details in the process of installing the components, as they were packaged for the distribution I use (ArchLinux) and my environment did not need a strong separation into a virtual environment. So these steps are rather easy and better explained on the official website.

Continue reading