Tag Archives: modules

Getting Drupal Modules using Python

A good friend of mine wrote yesterday a small python script that allows the user to search and download Drupal modules directly via the official ftp.
This was made since it is quite boring/irritating to first browse through the module page on drupal.org and then copy the link to a shell where you download the module you want on your web server.

Instead, Jonas (that’s my friends name, btw) wrote this program that directly scans through the drupal module directory on the ftp and returns the output in a shell where the user just enter the choice that he/she wants. Example:

jonas@thinkpad61:~$ ./idm.py hello
Found 32436 files!
[0] hellomobile-5.x-1.0.tar.gz
[1] hellomobile-5.x-1.1.tar.gz
[2] hellomobile-5.x-1.x-dev.tar.gz
[3] hellotxt-6.x-1.x-dev.tar.gz
Which module do you want to download? 1
Ok, lets get hellomobile-5.x-1.1.tar.gz
jonas@thinkpad61:~$ ls -l hellomobile-5.x-1.1.tar.gz
-rw-r--r-- 1 jonas jonas 824473 2009-10-22 22:34 hellomobile-5.x-1.1.tar.gz

I believe that this is quite usefull and interesting. But, as Jonas mentions in this post. It does not contain the functions that you might need, such as: version filter and dev filter. Meaning that you don’t want to see results for drupal 5 if you are running six. Nor do you want to use developer packages when you are in a critical installation.

I had some time so I made some improvements on the original:

tomburk@linux-e9bm:~> python idm-mf.py --help
Usage: idm-mf.py [options]

-h, --help            show this help message and exit
-f version, --filter=version
Filter the results in version numbers.
-d, --dev             Show developer packages

This allows the user to filter between the version, of course “all” can be applied, if one wants to show all the results. Plus, It’s possible to toggle between showing the developer packages or not.

Final result:

tomburk@linux-e9bm:~> python idm-mf.py -f 5 hello
Found a total of 32451 files!
Files containing "hello"
 Based on filter: 5
  Not showing developer packages
[0] hellomobile-5.x-1.0.tar.gz
[1] hellomobile-5.x-1.1.tar.gz
Which module do you want to download? 1
Ok, lets get hellomobile-5.x-1.1.tar.gz
tomburk@linux-e9bm:~> ls -s hellomobile-5.x-1.1.tar.gz
812 hellomobile-5.x-1.1.tar.gz

The file is available here: http://marcusfollrud.net/wp-content/idm-mf.py
Or at github: http://github.com/marcusfollrud/idm
See you!

A small update

2009-10-24 – Added support for multiple file download, Available on both github and in wp-content