Tag search
Package Management Sudoku
Russell Coker recently wrote a post entitled “Ownership of the Local SE Linux Policy”. This post has nothing to do with the substance of his post, which is a discussion of how distributions should configure SELinux by default. I know nothing about SELinux, but something that Russell said in passing caught my attention:
I am not aware of the Debian package dependencies (or those of any other distribution) being about to represent that the postfix package depends on selinux-policy-default-postfix if and only if the selinux-policy-default package is installed. Please note that I am not suggesting that we add support for such things, a package management system that can solve Sudoku based on package dependency rules is not something that I think would be useful or worth having.
As it happens, a little-known fact about the Debian packaging system is that you can, in fact, describe Sudoku puzzles in it!
From: Daniel Burrows’ Blog.
Automatically generate PHP documentation from Subversion with phpDocumentor
by Sander MarechalThe longer I program, the more structured my programming methods have become. Gone are the days of editing live spaghetti code directly on the server or frantic FTPing files after each tiny change. Today I not only stuff everything in Subversion just to keep track of changes, I also use it as a deployment mechanism. But I want more and I want it automated too! Currently I am busy playing with generated documentation and unit testing. Generated documentation is an all round great idea, but it has a drawback: You need to generate it all the time. So I set out to use Subversion’s post-commit hook to generate fresh documentation for my PHP projects using phpDocumentor.
I have written a little Python script that you can call from Subversion’s post commit hook. This script scans your subversion project for files that have the phpdoc property set. If any of these have changed, then it regenerates your documentation using phpDocumentor. It can also deal with files that are not kept in your Subversion repository and supports anything also supported by phpDocumentor.
Tags: php phpdocumentor subversion python documentation
Automagically convert Python objects to MySQL
by Sander MarechalI recently ran into an annoying little snag when using MySQL. Apparently MySQL cannot handle ISO 8601 datetime variables such as used by XML-RPC that use the format YYYYMMDDTHH:MM:SS. MySQL will simply convert such values to 0000-00-00 00:00:00 with a warning, so I was faced with the unpleasant prospect of converting all my XML-RPC dateTime values to something MySQL could understand.
I searched for a way to do this automatically and I came across a way tucked inside the MySQLdb Python module. MySQLdb contains a list of conversion functions and datatypes between MySQL's column types and Python's datatypes. It is possible to extend this list and pass it to the connect() method and have any datatype supported that you want. Here's how to do it.
A simple unix/linux daemon in Python
by Sander MarechalI've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone!
Update 2009-05-31: An anonymous contributor has written a version of the Daemon class suitable for Python 3.x.
Python-gstreamer, threading and the main loop
by Sander MarechalThis is just a quick heads-up for people who try to use python-gstreamer in a thread. Threading in Python has a few unexpected problems if you're new to it and it took me quite a few hours on Google searching for some scraps of documentation (and even diving into the source) before I got it right.
As it turns out, Python doesn't use Operating System threads but implements it's own threading because of portability, but that threading only works within python. When a thread calls a function that's written in C—such as gobject.run()—then Python freezes all threads until that function returns (unless that C function is wrapped in Py_BEGIN_ALLOW_THREADS/Py_BEGIN_ALLOW_THREADS statements). This is called Global Interpreter Lock or GIL and is very annoying when using gstreamer because gstreamer relies on some sort of external mainloop to function.
Streaming audio over TCP with python-gstreamer
by Sander MarechalI've fallen in love with Python. I'm always on the lookout for a good excuse to learn a new programming language. So, when I wanted something that lets me play my music collection from my server to my stereo I took python for a good test drive. Anoher thing I wanted an excuse for was learning gstreamer, so naturally I picked python-gstreamer.
Sadly there's a huge lack of documentation for it.There are only a few good tutorials around, first and foremost Jona Bacon's excellent tutorials [1][2][3]. I wanted my hack to work over TCP as well, because I have multiple music libraries. One on my home server, one on my desktop, a bit more on my laptop, etcetera. I want to be able to stream from other machines to my server which I'll hook up to my stereo. I could not find any tutorials on using tcpserversource and tcpclientsink elements, so honoring Jona's request that everyone “should write an article about something that you have discovered that isn’t particularly well documented”, here's mine about tcpserversource and tcpclientsink.