Tuesday, November 29, 2011

How to make your wireless card work with Network Manager after Debian 6.0.3 "squeeze" installation

I have a pretty old HP Pavilion dv1000 laptop with a Intel Pentium M Processor 740 at 1.7 GHz. I have always used Ubuntu along with the pre-installed version of Windows on that machine, but as new releases became more resource-hungry, I started to experience an unacceptable slowdown. Of course you can use a lighter window manager, such as Xcfe, but since I'm too affectionate to GNOME 2 I decided to make a new start with Debian. I then downloaded the latest 6.0.3 stable release and burnt it on a CD-RW (the other option is to boot the installer from the net, since it seems that you can't boot anything from removable USB media).

The installation process of my new OS went just fine, but in order to download updated packages from the internet I had to use my cable connection, since the Intel wifi adapter needed proprietary firmware that wasn't shipped with the first Debian CD. So I configured my ethernet card, and this turned out to be a source of problems, maybe the one you are experiencing now if you are reading this little guide. During the installation I had configured my ethernet to a static IP address, and everything went fine, Debian booted beautifully, fast and clean.

The first thing I did then was to install the Intel wifi adapter firmware in order to make my wifi card work properly. I have then enabled the non-free part of the official Debian repositories in my sources.list file and executed the following command

# apt-get update && apt-get install firmware-ipw2x00 wireless-tools

Then I have restarted the networking service and Network Manager with

# /etc/init.d/networking restart
# /etc/init.d/network-manager restart

At this point I configured my wireless connection with the graphical frontend to Network Manager (accessible through the icon in the notification area, usually near the clock on the top-right corner of the desktop) and...surprise! The association with the access point went just fine, but I couldn't ping my router nor any other machine on the local network. Weird, uh?

It turned out that this issue was related to the previous network configuration, the one carried out during the OS installation process, since in that case the installer wasn't supposed to use Network Manager to manage the connection. The solution is then pretty simple, I just had to edit my /etc/network/interfaces to look like the following minimal example

auto lo
iface lo inet loopback

and after rebooting my wifi adapter started working like a charm again.

As a final remark I'd like to inform you that with Intel Wifi ipw2200 adapters you might need to use the firmware version 3.0 for the WEP security encryption. So the best thing to do is probably to move to a more secure encryption protocol, like WPA or WPA2.

Sunday, June 26, 2011

Google Books plugin for Referencer

I'm going to break this rather long silence with a post on a plugin for Referencer.

Referencer is a GNOME application especially designed for scientists, for it organizes any type of documents BiBTeX can handle, and ultimately allows you to export the whole collection into a single BiBTeX file (see this article @ Wikipedia and the project homepage for more details). Among the capabilities of Referencer there is the possibility of adding references from ID like the DOI code or the arXiv identifier. One feature that is still lacking is that of adding documents from web urls, although you can create an empty reference with only the field "url" filled. Since I'm currently working on my thesis for my Master's degree in Theoretical Physics, I need a plugin that instructs Referencer how to fetch books metadata from a web page containing the description of books. One of such sites is the fabled Google Books and in what follows I'm going to explain why I've chosen this particular site. If you search a book on Google Books, go on its details page (if you're in the preview page, just click on "About this book" on the left) and scroll down to the bottom of the page. There you'll find three buttons that will allow you export the bibliographic metadata in three different format. Fortunately one of such formats is BiBTeX, and Referencer is able to fill a document metadata from a bibtex file. I then wrote a plugin that allows to fetch this bibtex file from Google Books by pasting the address of the book into Referencer.

How to install the plugin:
  1. download the plugin file gbooks.py from here;
  2. put gbooks.py into directory ~/.referencer/plugin (you might need to create this folder);
  3. run Referencer and enable gbooks if not already enabled.

How to use this plugin:
  1. run Referencer and go to menu entry Documents->Add reference with ID...
  2. select Web URL from the dropdown menu
  3. paste the Google Books url in the text field and press OK

Sunday, January 16, 2011

pyGtkPlot: yet another graphical front-end for gnuplot

The main window of pyGtkPlot.
As the title of this post suggests, I'm going to introduce to you a new graphical interface for gnuplot. The name of the project, pyGtkPlot, surely synthesizes the programming language employed and the target window manager: python and gnome/gtk+ respectively. This project has a (not so) old C ancestor, the gtkplot project at sourceforge.net (a C++ translation was on its way, but was never released to the public, and probably it'll never be). Since the development of the C and C++ version was becoming very slow due to the fact that the team of developers was composed of only one member (:P), that very same one member decided to turn his head towards python. This important decision took some time to become reality, because basically that implied the choice between performances and development speed, but now the pyGtkPlot has officially came to life, and it is hosted at Launchpad.net. There are no stable releases at the moment, but you may consider each new revision as a release candidate. This is because pyGtkPlot embeds the gnuplot x11 terminal inside its graphical interface (for this to work you must have the latest version of gnuplot installed on your linux machine), still retaining all the original interactiveness of gnuplot. Moreover you have the opportunity of sending commands to gnuplot directly, as though you were running it from a console. The only difference is that you have some additional aids at your disposal coming from the surrounding gtk+ widgets of the interface, which will increase in number at each new code revision pushed on Launchpad.

Basically, you start with a new gnuplot session with default settings and add new plots by configuring the panel at the left and then clicking o the + (Add) button in the toolbar, or the Edit -> Add menu entry (keyb. shortcut: Alt + a). You can save the current session for later uses or load a previously saved session in order to modify it or export the plots in different formats, actually in all the terminal supported by your installation of gnuplot (of course you may not want to choose a terminal that does not write to a file, like wxt or x11 :P). You can embed mathatematical formulae too using LaTeX syntax and export in png format directly (check the menu File for this). But, as ever, the best way to learn how to use pyGtkPlot is by playing around with its commands.

Monday, January 3, 2011

How to implement a non-blocking two-way pipe in Python

I was surprised by the lack of a way to read from a stream without blocking in Python, and this is the main reason why I'm writing this post. Some years ago I had the urge to open a two-way channel of communication between the program I was writing and an external command-line program (actually a GUI). I had solved this problem in mainly two different ways in C and C++ on Unix, by using pseudo-terminals in one case, and duplicated file descriptors in the other. Here we are going to create an object which inherits from a preexisting class which is provided by one of the modules for Python.