Python

Announcing flake8-diff

Purpose

This utility allows you to run flake8 over a set of changed files and filter out violations that would be introduced by merging those changes.

We use this as part of our build / CI infrastructure to alert developers opening pull requests to new violations their pull request will introduce, if it were merged.


Read more

Share Comments

Forking background processes in Python

This post attempts to explain how to fork child processes in Python, or at least how to use forking on an existing Python script. For some strange reason I’ve had to explain this a few times recently, so I decided an easy to reference blog post would probably make life a little easier.


Read more

Share Comments

Replacing Django's Nasty 'runserver'

Have you ever tried to have more than one person view a development site using Django’s built-in development server ? Yeah, it really sucks. Apparently concurrency wasn’t high on the features list and they have stated that it never will be.


Read more

Share Comments

Natural order sorting strings with numbers

The following python code makes natural sorting sequences of lexical and numerical values a little easier. It supports any iterable containing strings which have embedded numbers. In short it would give you this:

foo1 < foo2 < foo10

instead of this:

foo1 < foo10 < foo2


Read more

Share Comments

Generating a dependency graph for Postgres DB

This post was mostly inspired by this one, which shows how to generate a dependency graph for a MySQL database. Here we do something similar for PostgreSQL.

This script will generate the required digraph data to pipe into graphviz dot which will generate a visual representation of dependencies in a database schema, based on foreign key constraints.


Read more

Share Comments

Extending Python with modules written in C

Using C (or C++) to create Python modules is really quite simple, providing you know a little C of course. I recently had to do some work around getting a bunch of legacy C code talking to a newer system and thought I’d post a nice simple example of how the Python extensions work.

This code gives you a single method “do()” that will print the output of a command, passed to it as a string, to stdout and return the exit code as a python int.


Read more

Share Comments

Simple OpenVPN Server Statistics

Ever wondered what the status of your OpenVPN server is, or wanted some simple stats ?


Read more

Share Comments