Archive for the ‘Python’ Category

Improve jhbuild downloading

Friday, April 11th, 2008

Yesterday, I tried to install Gnome Online Desktop. Since, this is fairly new, it has to be build from the source. Gnome Online Desktop is a complete branch of gnome desktop, which will of course have many dependencies. It’ll take years to download each and compile manually. That’s why they have jhbuild (it works like gentoo emerge).

This is April, which is supposed to be the best month of Sri Lanka with festivals/celebration. But there is a price to pay, thundering (Last year, lighting took my laptop :( ). My connection goes down for each 10 minutes.

So, while jhbuild downloading a module, the connection goes down, and when I restart jhbuild, download doesn’t continue from where I left off. It downloads the whole file again. So, here is a very simple one line hack to prevent that from happening to you.

In jhbuild/versioncontrol/tarball.py, line 171, add a command line option “-c” to wget command. If you are not happy with “wget”, you can change it to whatever you want(prozilla,aget,d4x).

I’m still building online desktop (101 packages :-/ ), can’t wait to see what it can do.

The Python Challenge

Sunday, September 16th, 2007

You might have already read my blog post about deathball riddle. Few days ago, I started doing another internet riddle, but not like deathball, this is a programming riddle. It’s python challenge.

You might not familiar with python, but this is definitely a really good way to learn the language. When, I started doing this, I only knew few syntax in python.. But after finishing several levels, I learned about some really good ways of using python - or I can say the art of python.

If you don’t know about python, It’s not a dead language or not a useless language. It’s quite powerful scripting language, which also have GTK bindings. Many of the novel linux apps are written in python. Gentoo emerge is a very good example.

Enhance Apt-Get downloading using an external download accelerator(axel/prozilla/aget)

Wednesday, February 14th, 2007

The Apt-Get in debian systems use their own downloading system to download packages from the internet. It supports file resuming and pipelining. However, it doesn’t support downloading using multiple threads, and it won’t allow you to external applications to download.

However, the http downloader is a separate application(/usr/lib/apt/methods/http) from apt-get, and the apt-get spawns the executable to download the files. Those two programs communicate via stdin and stdout. I have written a new downloading application which can communicate with the apt-get. So, I just copied the executable to /usr/lib/apt/methods/http. The new application spawns another program(In my case a shell script) with two arguments; the url and the local file.

So, after all my shell script calls a python script. My program doesn’t call the python script directly because when the python scripts gives some output to stdout/stderr the apt-get program crashes. So, my shell script redirects the all output to /dev/null. Then, the python script will get the url, do a HEAD request, get the file size. If the file size is less than 100K, it’ll execute wget, if not it’ll execute axel. So, the files will get downloaded and apt-get will install the software.

The apt-get update command fetches many small files from the same server. Since the original downloader uses pipelining, it’s much faster. I have to modify my code to do something about pipelining.

Files :

scripts.tar.gz

apt.tar.gz