The listmodules CGI Script
Fredrik Lundh | October 2006 | Originally posted to online.effbot.org
Hidden in the documentation source directory in 2.5 is a small script that lists all available modules for a Python installation:
$ python Doc/tools/listmodules.py # module list (generated by listmodules.py) # # timestamp='20061009T060000Z' # sys.version='2.2.3' # sys.platform='sunos5' # BaseHTTPServer Bastion CGIHTTPServer Canvas ConfigParser ...
I recently found myself doing some work on a web server with an old and somewhat incomplete Python installation, and no shell access, so I ended up adding a CGI interface to the script. Here’s the code:
and here’s how to use it:
- Download the script to your machine.
- Edit the script’s “#!” line so it points to the Python interpreter on your server.
- Upload the script to the server, and put it somewhere where you can install Python CGI scripts. Make sure it’s executable.
- Point to the corresponding URL from a web browser.
If everything went well, the script will print a list of all available standard modules, sorted in lexical order.
To get a list of all modules, remove the block that follows the “get rid of site packages” comment.
(Note that this script should only be used temporarily, and for your own personal use. Your ISP probably won’t appreciate if you publish a link to a live instance of this CGI script.)