Archive for the 'Python' Category

Enhanced Python AllOfMp3.com downloader

I’ve been working on a hacked version of r00tshell’s Python “All Of Mp3 music downloader“; The idea is to take his research into exactly how to connect to the All of MP3 music download service and re-package it as a friendly, testable, deployable python program.

It’s not finished yet, however the key advantages my version ought to offer will include:
* Fully Object-Oriented Design - This will encourage code-reuse, e.g. somebody could build the class into a QT or GTK based graphical application.
* Support for multi-threaded downloading - This allows users to download multiple files at a time.
* Support for file organisation - This will allow files to be sorted into subdirectories based on their ogg/id3 metadata.

My work is on my subversion archive. The original version can be found on r00tshell’s subversion.

LibDems vague on software patents

At the IT conference I am attending, the organisers conducted a straw poll of who opposed the impending Euro-software patent legislation. Everybody I saw was against it; The unambiguous conclusion is that software patents are harmful and the ‘economic majority’ of Europe’s IT industry who oppose software patenting.

In essence, a patent grants a monopoly on an idea. Patents were invented hundreds of years ago to protect the investments made by inventors. In return for publishing the designs of an invention (e.g. the plans of your contraption), and agreeing to license the idea for a standard fee, the government would protect that monopoly. This worked back in the 18th century because other inventors could study the designs in the patent-office and invent better machines.

The assumption of many MEPs appears to be that since patents appear to work quite well for contraptions they must also benefit software inventions. However there are critical differences between the world of software and the mechanical age that spawned the patent.

A central principle of computer-science is idea-reuse: Software languages are built to encapsulate ideas and re-use them. Any programmer can download ‘modules’ - collections of working functions. Some functions implement simple, single-minded ideas. Others amalgamate thousands of the simpler functions and can do complex things. The programs that you or I use in our day to day work are made of thousands of these complex functions, so it’s not unusual for any substantial work to contain millions of potentially patentable ideas.

Unlike a car or a steam-engine, a useful program is almost never a totally original work because re-use of ideas is so fundamental to what we do. The programmer who works at the leading edge of technology will almost certainly not be aware of which of the millions of ideas in a program are patented, and therefore any substantial program is likely to blunder into the patent minefield.

Software patents drive up the cost of innovation. Since any program is potentially infringing then all commercial software must be scoured for potentially infringing code before it can be sold. Of course, companies could opt to remain ignorant of their potential patent infringements, but if convicted of a patent violation the costs are enough to bankrupt most firms. Most companies would rather spend 10% to 20% of their annual profits on lawyers to audit their products.

In addition, rather than re-investing their remaining profits back into development, companies will feel pressured into building their own patent arsenals. A patent typically costs between £30k and £100k, so the more money we send to the patent office, the fewer productive computer-scientists we can afford to employ. This is why software patents cost jobs.

According to a friend who moves in parliamentary circles, there is at least one LibDem MEP who has not yet made his mind up about software patents. He told the FFII that if they can present two hundred signatures opposing software patents he would vote against the legislation. We managed to collect more than 250 from the delegates in the space of half an hour: a unanimous response against software patents

I believe that a vote for software patenting is misguided and harmful because it makes the best-practices of software development into something that is legally risky. In theory, any program that I write that is substantially useful has the potential to infringe somebody’s patents. The risk of accidental patent infringement will turn today’s playing-field into a minefield.

Software patents will harm me, and they will harm my customers. If any MEPs are readinf this, I request that you against software patents.

Europython Conference, Day Zero

I’m off to the Europython conference; My heart is aflutter because I’m running rather late and I know how bad the queues for budget air-lines can be. I’ve never travelled on Ryan-air before and I am expecting the very worst possible experience. This is conference day zero because technically it does not start until tomorrow and in any case all good computer scientists make a habit of counting from zero.

Initially I was expecting a weak line-up; At the time I registered the presentation roster was empty and the attendee list was meagre; but in the last few weeks both have grown and I’m quite impressed at what the conference management have achieved. I’ve barely been able to keep up with the high-bandwidth conference mailing list.

This is also the first Open-Source conference I have attended; I’ve been told by frequent conference attendees to lower my expectations. Open source conferences have a minimal budget and therefore lack even the most rudimentary glitz; This will be a glitz free zone.

My accommodation is going to be a shared room in a student’s union owed building. I booked the cheapest kind of room available, so I will be sharing with three others; All will be python developers like myself; I have no idea who these individuals will be.

And what a fool I am; I’m still plagued by nagging doubts; What if there are two cities in Europe called Gothenburg, one in Sweden (where I am headed), but another somewhere far far away, perhaps in a destination that I will not possibly be able to afford to fly to. And I will be forced to spend a fruitless three nights in a cold Nordic country, all alone and unloved.

In any case; All my fears may be for nothing; I might not even get to the airport at this rate. As I type this, the train has been stuck on the tracks outside Stanstead for the last fifteen minutes, going absolutely nowhere.

pod.py - A minimal cross-platform “podcatcher”

I’ve been listening to a lot of podcasts recently; a particular favourite is “Escape Pod“, a weekly podcast which aims to revive the genre of the science-fiction short-story. The standard podcast reciever is iPodder, a very feature rich program that is just too bloated for my needs: I want a cross platform downloader that can be scheduled from UNIX cron and works from the command line.

I went hunting for an alternative client. The best I could find was Bashpodder: a pure bash podcast downloader. Bashpod features some of the best shell-scripting I have ever seen, but even code of this quality is a little bt ugly for me; Of course, what I really wanted was a Python based podcast reciever.

So I created pod.py - a pure Python Podcast reciever. It depends on the excellent 4suite XML processing library to do all the hard XML processing. If you want to try it out, you can get it from my subversion archive: http://svn.stodge.org/pod.py/trunk/

Instructions

1. Get the program: If you want to check the program out, and you have the command-line subversion program installed, you can type:

svn co http://svn.stodge.org/pod.py/trunk/

You also need to download 4suite. On windows you might need to download an run an installer. On Gentoo Linux you might need to type something like:

emerge -uD 4suite

2. Install the program: You can use python’s standard distutils isntaller to help you out:

python setup.py install

The program should now be installed. It’s really easy to use:

3. Use the program:

pod.py url -d downlaod directory

So for example, if I want to download BBC’s “In Our Time” podcast to a folder called ‘my_podcasts’, I can issue the following incantation:

pod.py http://downloads.bbc.co.uk/rmhttp/downloadtrial/radio4/inourtime/rss.xml -d /home/sal/my_podcasts

The Python Challenge

I’ve not spend much time blogging recently; this is because I have been puzzling through “The Python Challenge” - a sequence of 30 riddles intended to test the mettle of python developers.

Each challenge takes the form of a web-page; usually with a cryptic or hidden clue waiting to be found. If you have managed to identify the nature of the puzzle, the solution normally requires the player to write a short python script in order to discover the next password; These puzzles are devised in such a way to force the player to investigate rarely used python modules, or consider new ways of using the familiar ones.

For example, one puzzle has the player writing a script to extract a hidden message from something vaguely resembling a barcode hidden in an image; Having recognised that the image contains a coded message, the player must find a tool that will allow the message to be extracted, and if you are lucky, that contains a cryptic clue that will lead you on to the next puzzle.

The delight of the Python Challenge is the variety of techniques a developer must acquire in order to complete the sequence. Just like the real world, programming skill alone will not give you the solution; one must first recognise the problem and devise a strategy. Writing the program is usually the smallest part of each challenge – investigating the problem and ruling-out the various blind-alleys forms the bulk of it.

I’m on puzzle 10 out of 30, so you can expect me to stay quiet for the next week or so.

No ‘Rails’ for Python

I’ve become curious about ‘Ruby on Rails‘ much in the same way that I might become curious about a noisy party going on next-door at 4am on a work-night. Shall I get out of bed and see whats going on? Naah.

I think the author of this article, is quite big on Quixote, which is supposed to be yet another web application framework for Python.

I think for now I will stick with Zope.