Thursday, 20 December 2012

My Blog Stats

One nice feature of blogger is the stats page. It gives a nice summary of viewer activity.

Here's mine captured today.

USA > UK > Germany.

59% are windows users.
28% are marked as "linux" (whatever the heck that means).

and chrome > firefox.


Wednesday, 19 December 2012

Python, PyQt, Qt and windows - legal issues

I write GPLv3 applications using python and pyqt4, and by association Qt.

I build binaries mainly for Debian based gnu/linux distributions. Consequently, I let the mighty apt take responsibility for a valid python and pyqt environment. Up until now, therefore, I am simply distributing my own code.

Recently, however, I have been playing with creating packages for windows. Using Pyinstaller I can build executables which pull all my python and qt dependencies and roll them into either a single folder, or even a single *.exe .

These give me cause for concern however, as these standalone executables contain several files I believe I am unlicensed to redistribute. Those files come from 2 sources.

  1. microsoft themselves.
    • Microsoft.VC90.CRT.manifest
    • msvcm90.dll
    • msvcp90.dll
    • msvcr90.dll
  2. and pyqt/qt stuff (see below for full list)

In conjunction with Wix I can go even further and create an *.msi package which helps for clean installation, removal and upgrading of my application. I believe most application developers using these very same tools on windows simply do exactly this and don't care about the legal and moral issues here. I, however, am not content to do this and believe I need to find a way to comply with the licensing terms of microsoft, qt and pyqt4.

I believe one possibility is to write a separate application in conjunction with the Wix installer to emulate apt and install those components separately.

I would welcome comments from anyone who has addressed this problem.

Here are the files produced by one particular (non-trivial) PyQt4 application of mine.
$ ls -lR rotagen/
        71680 Jul  4  2010 bz2.pyd
      1019904 Oct 20  2010 LIBEAY32.dll
         1857 Nov  7  2007 Microsoft.VC90.CRT.manifest
       224768 Nov  6  2007 msvcm90.dll
       568832 Nov  7  2007 msvcp90.dll
       655872 Nov  7  2007 msvcr90.dll
       266752 Nov 11  2010 phonon4.dll
      1594880 Dec 24  2010 PyQt4.QtCore.pyd
      5670912 Dec 24  2010 PyQt4.QtGui.pyd
       468480 Dec 24  2010 PyQt4.QtNetwork.pyd
       304640 Dec 24  2010 PyQt4.QtWebKit.pyd
      2286080 Jul  4  2010 python27.dll
      2238464 Nov 11  2010 QtCore4.dll
      7943168 Nov 11  2010 QtGui4.dll
       891392 Nov 11  2010 QtNetwork4.dll
       674816 Nov 11  2010 QtOpenGL4.dll
       276480 Nov 11  2010 QtSvg4.dll
     10843136 Nov 11  2010 QtWebKit4.dll
       339456 Nov 11  2010 QtXml4.dll
      1009069 Dec 16 11:10 rotagen.exe
          730 Dec 16 11:10 rotagen.exe.manifest
        11776 Jul  4  2010 select.pyd
        66560 Dec 24  2010 sip.pyd
       209920 Oct 20  2010 SSLEAY32.dll
       688128 Jul  4  2010 unicodedata.pyd

         21451 Dec  6  2009 pyconfig.h

         141824 Nov 11  2010 qcncodecs4.dll
         167936 Nov 11  2010 qjpcodecs4.dll
          77824 Nov 11  2010 qkrcodecs4.dll
         155136 Nov 11  2010 qtwcodecs4.dll

         14336 Nov 11  2010 qglgraphicssystem4.dll

         36864 Nov 11  2010 qsvgicon4.dll

          26624 Nov 11  2010 qgif4.dll
          28672 Nov 11  2010 qico4.dll
         196096 Nov 11  2010 qjpeg4.dll
         220672 Nov 11  2010 qmng4.dll
          22016 Nov 11  2010 qsvg4.dll
         284672 Nov 11  2010 qtiff4.dll

Batch Converting Video for Nexus7 with ffmpeg.

The title says it all, I have a folder of videos, and want to have them play on my Nexus 7 Android device.
In other words, I want to be able to do this:-

~$ cd Videos
~$ somescript *.avi|*.mov|*.mpeg

then go to bed and wake up with nexus 7 supported files.

Here is my version of that script.
#! /bin/bash

# script to convert video files to nexus (android) devices #

This script will convert video files to the preferred format for android devices\n
It uses ffmpeg to do a 2 pass encoding.\n
convert quicktime movies\n
~$ ./\n
convert mpgs\n
~$ ./ video_file.mpg\n
convert avis\n
~$ ./ video_file.avi\n
wildcard use is supported, and unique filenames for the output 
videos should ensue by simply prefixing .mp4\n
~$ ./ *.avi\n

function show_help {
    echo -e $HELP
    exit 1

 ffmpeg -i $SRC -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null && \
 ffmpeg -i $SRC -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -ac 2 -sameq -pass 2 $DEST

if [[ "$1" == "" ]]

while [[ "$1" != "" ]]; do
 convert $1

exit 1

Saturday, 10 November 2012

mythtv 0 byte recordings

there seems to be a problem going around where mythtv is failing to record shows (on DVB tuners) and recording that the show HAS been recorded, but with a zero byte file size.

I have had this happen on my machine, which is currently running mythbuntu 12.10 64 bit.

When it happens on my machine, further recordings and live tv all fail too.
A quick google gives me the following impression.

  1. This seems to happen when folks have multiple DVB tuners.
  2. setting "quick tuning" to always may help.
  3. altering the vmalloc of your kernel may give the DVB cards more headroom? (perhaps multiple tuners, along with nvidia graphics blobs can quickly use up the default 128M?)

so, as I am in category 1, I have tried fixes 2 and 3. incidentally, fix 3 should be done in this manner for most grub2 based distros.

sudo nano /etc/default/grub
change the line which looks this (you may have other options already like splash)
by appending vmalloc=512M ie..
GRUB_CMDLINE_LINUX_DEFAULT="quiet vmalloc=512M" 
then save & run
"sudo update-grub"

I've done this.. I'll let you know if it doesn't work (might be 2 weeks before the next program is missed, and I'll bet it is my wife's favourite gardening program again)

Tuesday, 23 October 2012

MySQLdb Gotcha!!

I pushed a relatively minor upgrade to my openmolar program today to find it broken on the debian squeeze boxes I use in the surgeries here.

"What happened?", you may ask.

Consider this (python) code.
import MySQLdb
db = MySQLdb.connect(db="openmolar", user="academy", passwd="XXXXXX")
cursor = db.cursor()

query = '''INSERT INTO notes (ndate, serialno, note)
           VALUES (DATE(NOW()), %s, %s)'''

values = ((1, "hello"), (1, "world"))

cursor.executemany(query, values)
this code works with python-mysqldb 1.2.3 (on debian wheezy), but not python-mysqldb 1.2.2 (debian squeeze). the error I get is
TypeError: not all arguments converted during string formatting
it seems that being able to include MySQL functions (ie. the DATE(NOW()) bit) in the values tuple is only recently supported. what is surprising, however, is that this can be done with single executions.. eg.
cursor.execute(query, (1, "hello"))
Obviously, this is not consistent behaviour, and has been fixed in the current release, but it does demonstrate a hazard for developers who target various gnu/linux distros. (yes, I know I should have a test suite... ) FOLLOW-UP - I looked into the python-mysqldb sources, and found the culprit to be an improved regex lookup introduced in

Wednesday, 22 August 2012

openmolar2 - update on progress

I've been asked to give an update on openmolar2, and where it is at.

I am very, very happy with progress, to be honest, although I realise that it is presently a set of libraries, rather than a useable set of applications.

Here, however, are some screenshots which should give some indication of what I have been playing at.

OpenMolar version2 is very different from the "rushed by necessity" openmolar which I still utilise daily in my practice. It has 3 components. A server management tool (a daemon running on the same unix machine as the postgresql server), an administrative application, and a client.

Here are some screenshots.

More information at The project homepage.

So this is the startup page for a configured admin application. It is configured to report on three openmolar servers, and has connected to 2 of them.
One important thing of note.. The admin application can tell you exactly who is connected, and their IP address (or "None" for a unix socket.. I need to fix that!)

Populating a new database with demo data.
Exploring/Editing the tables of that database.

Making a Query on that database.

And finally... using the client application for a graphical view of a (fictitious) patient's data.

Friday, 27 July 2012

Configuring Reprepro for apt-file

I use reprepro to manage my debian/ubuntu repos.
I noticed, however that apt-file search didn't return results.. so what had I confgured incorrectly?

answer (provided by Daviey from the Ubuntu UK Podcast).
I needed to add the following line to each distribution in conf/distributions.

Contents: .gz

after that I ran "reprepro export" to update the indices. Job done.

Now to test it.

~$ apt-file update
~$ apt-file search
openmolar-orig: /usr/lib/python2.6/dist-packages/openmolar/
openmolar-orig: /usr/lib/python2.7/dist-packages/openmolar/
openmolar-orig: /usr/share/pyshared/openmolar/


Wednesday, 25 July 2012


Sikuli is really cool.

could be a good way to write gui tests?

Saturday, 21 July 2012

Low Carb Experiment

Wondering if I'll regret posting this. Probably. But here goes.

For the last 3 weeks I have been experimenting with a very low carbohydrate lifestyle.
No sugar, refined starch (bread rice potatoes). 

And I have just weighed myself.
I am 83kg.

I was 88kg three weeks ago, and have been consistently around that weight for about 20 years (with the exception of when I was training very heavily for the world masters rowing event in 2005, when I was down to 83kg.).

Conclusion - for weight loss, and for me as an individual, a low carb diet is very effective.

However, I am pleasantly surprised by some other observations.

I no longer fart. Haven't "bottom burped" in days. For anyone who knows me well enough (perhaps to have shared a long car journey with me) you will know that is quite unusual.
My Urine is almost completely clear, and totally odourless.

TMI? sorry.

(I also have less back pain, feel less tired, and have fewer hayfever symptoms, but all that could be placebo, or due to the recent holiday in Corsica)

So my conclusion is that something in my "regular" eating habits does not agree with me. Gluten perhaps?

I have now to decide what my eating habits are going to be for the rest of my life. One thing is for sure, I am going to be VERY careful in re-introducing those foodstuffs.

And that, hopefully, is good news for my passengers ;)

if you are still reading.. my inspiration to try this was the experiences of computer scientist Steve Gibson of , and the following resources.

Book. (an extreme view in my opinion)

Nutrition podcast. (very, very sensible tips)

Saturday, 16 June 2012

Root partition space needed

Using pbuilder to target 5 distros (unstable, testing, stable, precise, lucid), and using apt-cacher to speed the process up, I'm running out of room on a drive parition (lots of stuff in /var/cache!). Going to create a separate var partition. If I am away for some time, this has gone badly.

Thursday, 14 June 2012

Facebook is shit.

2 weeks ago, at a Rotary Club meeting, fellow Rotarian James Martin convinced me that social networking had a place for all businesses. So, over the last 2 days, I revisited facebook with a view to maintaining a presence there for my dental practice. Here are my thoughts (the title is a synopsis).
  • IRC is better for casual social banter with like minded people.
  • twitter is better and less intrusive for knowing what folks are up to.
  • A self-published website is much better for fine control over your web presence, if you can't be bothered with the amount of work, something like blogger provides a very good alternative.
  • For video and photo hosting, many better alternatives again.
  • Old school Newsgroups and mailing lists are better for the argumentative type of discussion.

So what's so bad about Facebook?

I can't avoid it.
It is second rate in all of the above, but makes all this useable by totally non-techie types, some of whom I actually quite like. Worse though, is the "app extensions" where noise from outside (such as my daughter's school feed) which puts non-authored, non referenced, and simply PLAIN WRONG opinions out as if they are hers. I can't stand it when someone is WRONG on the internet and I can't personally flame them. Damn my OCD.

Wednesday, 16 May 2012

PyQt4 and audio playback with phonon

So today I wanted to try and use PyQt4 to play music. I couldn't find an example.. so here goes. first.. you need some obscure(ish) dependencies.
~$ sudo apt-get install python-qt4-phonon phonon-backend-gstreamer
then the following code should work. (choose your own music file of course!)
import sys
from PyQt4 import QtCore
from PyQt4.phonon import Phonon

app = QtCore.QCoreApplication(sys.argv)
app.setApplicationName("my_player") #phonon useage requires an application name

m = Phonon.MediaSource("/home/neil/Music/pop/ABC - All of My Heart.mp3")
obj = Phonon.createPlayer(Phonon.MusicCategory, m)


Sunday, 1 April 2012

btrfs and apt

Here on debian wheezy (testing), I note the mighty apt is doing a pretty big dist-upgrade this am.
I think btrfs could bring a bring a great safety net to such things.
Need to get 184 MB of archives.
~# apt-get dist-upgrade
Get:1 wheezy/main dpkg amd64 1.16.2 [2,327 kB]
. (etc..)
After this operation, 516 kB disk space will be freed.
Do you want to continue [Y/n]? Y
Create pre-installation snapshot with btrfs [Y/n] Y

That would enable a full rollback in case of any packaging hiccups?

Thursday, 22 March 2012

Distributing Plugins

So openmolar2 is progressing well, and like any sensible contemporary application, has a mechanism for "plugins".

Hopefully, if the Documentation is thorough, and I write a good tutorial, the barrier for even non-technical users to contribute should be lowered considerably. In addition, it should mean that the application doesn't "bloat" with functionality required by just a few practices.

Thanks to python, and the ability to run code directly from a zipped file archive, I also think the plugins are going to be able to work absolutely seamlessly to interact with pretty much any functionality of the 2 guis.

I am, however, a little perplexed at the best design for distributing these plugins.
The image on the right is a mockup of the website design, viewed by a dialog raised by the openmolar application.
This page can be viewed at

I have decided to write my own embedded webkit based browser for this because it gives my the following advantages.
  1. The Application can authenticate with the server and give version information for compatible plugins etc.
  2. The application can also tell the site which plugins are already in use.
  3. Downloading can go automatically to the correct folder (platform independent).

But here is my question.

Should I create a separate sub domain perhaps and self give it a self-signed certificate? or continue with the rapid-ssl certificate I already use for ? As the application would manage the client-side certification, I don't see a need to involve a third party.

A definate disadvantage, however, is the server side complexity of this and the dns lookup. Does using the existing domain and certificate make more sense?