The Free Geek

Ramblings of a Free Software Geek

Check GMail the Python way Mon, 31 Jul 2006 21:05:21 +0000

Filed under: Google, Programming, Python — Baishampayan @ 21:05:21

Swaroop posted a nifty Perl script to check GMail. The script basically parses an Atom feed of the latest 20 mails provided by Google. Since a Python hacker like Swaroop is dabbling in Perl, I thought it was my duty as a Python evangelist (or is it Pythangelist?) to show the people that the same thing can be achieved using Python with equal ease :) The main code is around 50% of the total code. A large portion of the code is used for the pretty printing. Here it is —

## check-gmail.py -- A command line util to check GMail -*- Python -*-

# ======================================================================
# Copyright (C) 2006 Baishampayan Ghose <b.ghose@ubuntu.com>
# Time-stamp: Mon Jul 31, 2006 20:45+0530
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
# ======================================================================

import urllib             # For BasicHTTPAuthentication
import feedparser         # For parsing the feed
from textwrap import wrap # For pretty printing assistance

_URL = "https://mail.google.com/gmail/feed/atom"

def auth():
    '''The method to do HTTPBasicAuthentication'''
    opener = urllib.FancyURLopener()
    f = opener.open(_URL)
    feed = f.read()
    return feed

def fill(text, width):
    '''A custom method to assist in pretty printing'''
    if len(text) < width:
        return text + ' '*(width-len(text))
    else:
        return text

def readmail(feed):
    '''Parse the Atom feed and print a summary'''
    atom = feedparser.parse(feed)
    print ""
    print atom.feed.title
    print "You have %s new mails" % len(atom.entries)
    # Mostly pretty printing magic
    print "+"+("-"*84)+"+"
    print "| Sl.|"+" Subject"+' '*48+"|"+" Author"+' '*15+"|"
    print "+"+("-"*84)+"+"
    for i in xrange(len(atom.entries)):
        print "| %s| %s| %s|" % (
            fill(str(i), 3),
            fill(wrap(atom.entries[i].title, 50)[0]+"[...]", 55),
            fill(wrap(atom.entries[i].author, 15)[0]+"[...]", 21))
    print "+"+("-"*84)+"+"

if __name__ == "__main__":
    f = auth()  # Do auth and then get the feed
    readmail(f) # Let the feed be chewed by feedparser

And here is a sample output —

ghoseb@trinka:~$ python check-gmail.py
Enter username for New mail feed at mail.google.com: foo.bar
Enter password for foo.bar in New mail feed at mail.google.com:

Gmail - Inbox for foo.bar@gmail.com
You have 20 new mails
+------------------------------------------------------------------------------------+
| Sl.| Subject                                                | Author               |
+------------------------------------------------------------------------------------+
| 0  | Strip Whitespace Middleware[...]                       | Will McCutchen ([...]|
| 1  | [FOSS Nepal] list of free alternatives to windows[...] | Manish Regmi (r[...] |
| 2  | json serialization[...]                                | Gábor Farkas (g[...] |
| 3  | editable=False and "Could not find Formfield or[...]   | Corey (coordt@e[...] |
| 4  | IronPython 1.0 release candidate[...]                  | Jeremy Dunck (j[...] |
| 5  | django server tree organization[...]                   | Kenneth[...]         |
| 6  | Project when using multiple sites[...]                 | Jay Parlar (par[...] |
| 7  | [FOSS Nepal] Neprog (nepali version pogrammer for[...] | ujwal (ujwal2@g[...] |
| 8  | Bug#379789: wrong keymap on Intel MacBook Pro[...]     | Frans Pop (elen[...] |
| 9  | debconf is Level 1?[...]                               | Clytie Siddall ([...]|
| 10 | Weird slowdown with dev server behind nat[...]         | Akatemik (tpiev[...] |
| 11 | Database API question: I am not able to return a[...]  | DavidA (david.a[...] |
| 12 | Bug#379120: lspci present on i386, verify on[...]      | Eddy Petrişor ([...] |
| 13 | New levels of D-I[...]                                 | Eddy Petrişor ([...] |
| 14 | Installed Apps in settings.py[...]                     | limodou (limodo[...] |
| 15 | where u at man ... where can i call you ??????[...]    | Sanjeev[...]         |
| 16 | unable to runser ?[...]                                | Geert[...]           |
| 17 | Bug#380585: debian 3.1 install FD[...]                 | as_hojoe (as_ho[...] |
| 18 | Re: Translated packages descriptions progress[...]     | Michael Bramer ([...]|
| 19 | Loading an url takes 60 sec.[...]                      | and_ltsk (andre[...] |
+------------------------------------------------------------------------------------+
ghoseb@trinka:~$

Well, the code is obviously pretty rough. It’s just for showing newbies how to use feedparser and urllib, two very powerful Python libraries. Improvements, patches are welcome :)

The text source can also be downloaded.

 

The Dell XPS m1210 — a mini review Thu, 20 Jul 2006 17:36:25 +0000

Filed under: General — Baishampayan @ 17:36:25

After a lot of research, I recently got a Dell XPS m1210 for my girl friend. It’s a cool 12.1″ WXGA laptop with pretty much cutting edge features. It has an Intel T2300 Core Duo processor and came with 1 GiB 667 MHz DDR2 SDRAM and a 80 GB SATA HDD. It also has the usual embellishments like DVD RW, Intel Pro Wireless, 9 cell battery etc. All this weighs just around 2 Kg and costs around 1500 USD. So it’ll neither break your back nor will it burn a hole in your kitty :)

It came with something called Dell Media Direct which is some kind of embedded DVD player and would run without an Operating System. I clean formatted the hard drive and tried to install Ubuntu 6.06 LTS “Dapper Drake” on it. But I was struck by a known bug in the Ubuntu installer which frustrated me a lot. I installed Ubuntu on it finally by avoiding the bug somehow and everything went just fine afterwards. I thought that I’d need to compile and install the Wireless drivers myself but I was pleased to see that Ubuntu included the binary firmware in its restricted modules package. So everything worked just “out of the box” :) It was pretty amazing to see great support for relatively new hardware in GNU/Linux. The only thing that I had to fix by hand was the display resolution. X.org could detect only 1024×768 resolution which not only looked bad, but due to the different aspect ratio things looked a bit stretched horizontally. I fixed the problem by using 915resolution to over-write the display BIOS. I added an entry for 1280×800 in an unused slot and that fixed the problem just fine.

As far as the performance of the laptop is concerned, it’s just amazing. It’s very fast considering its size and I am sure it will beat any laptop in its class. It takes only around 25 secs for Ubuntu to boot, and < 30 mins to rip a DVD. What else can I say, I can’t really complain. At last, a really portable as well as usable laptop. I am really feeling like keeping it for myself and handing over my 3 year old Toshiba to her.

Though almost everything works fine by default I guess it’d be good to have a comaptibility matrix. So here it is –

1. Processor (Intel T2300 Core Duo) Works Needs SMP kernel
2. DVD RW Drive (Sony) Works -
3 SATA Hard Disk (Hitachi) Works -
4. Ethernet (Broadcom BCM4401-B0) Works Needs b44 module
5. Wireless (Intel 3945abg) Works Needs ipw3945 module, firmware, etc.
6. Display (Intel 950) Works Needs 915resolution to get high resolution
7. Sound (Intel 82801G) Works Needs snd-hda-intel module
8. Firewire (Ricoh) Works Needs ieee1394 module
9. Modem (Intel) Haven’t tested, but should work Most probably will work with the snd-intel8×0m module
10. Card Reader (Ricoh) Somewhat works Works with SD, doesn’t work with MMC
11. ACPI Somewhat works Suspend to RAM doesn’t work yet

The things that don’t work at the moment will start working soon as and when newer kernels are released. The hardware is very new, so small issues can be expected. Over all, it’s a very nice laptop to buy. I haven’t faced any quirks with it and seems to be very stable. Final verdict — great buy, very good hardware and very good value for money.

Toufeeq has also written a nice review of his XPS m1210, though his configuration differs slightly with mine it’s very useful.

Dell XPS m1210

 

Of women and Free Software Mon, 17 Jul 2006 16:40:05 +0000

Filed under: Free Software, GNU/Linux, Open Source Software, Rants — Baishampayan @ 16:40:05

I came back from Bangalore just today and saw an apparently interesting blog post by Vidya (aka Svaksha). She talks about the problems that women in FOSS face and goes on to explain the reasons why there aren’t many females in the FOSS world. While a post like this is very much welcome, what concerns me are her pre-concieved notions about the whole picture. I would like to adress them one by one –

  • How is being rude important or necessary? How actually do you define rudeness? Nobody supports a rude person, notwithstanding the gender or the project. I agree that sometimes newbies are flamed, but that’s mostly because of not reading the manuals or asking stupid questions. Nobody gets flamed on the basis of his/her gender.
  • How is “survival” an issue here? All Free Software projects are open to all and everybody can contribute to them. Either you contribute or you don’t. It all depends on how motivated you are. You need to remember that you are _not_ doing us any favour by contributing in a Free Software project. You do it to scratch your own itch. If your itch is bad enough, you will scratch it no matter how inaccessible / tough / hostile that itch is. Ditto with Free Software. It’s wrong to expect people to welcome you a red carpet just because you are female or come from a poor country. This is a level playing field after all.
  • About women being made moderators of the Ubuntu-IN list, what makes you think that just being a female gives anybody the right to moderate a list or admin a server? Do you think this kind of favourism or reservation really helps? What about a situation where patches by female kernel hackers are given preference over male kernel hackers? It will just result in a bad and buggy kernel. Not because I think females can’t code (of course they can), but because the very idea of having reservtaions in a Free Software project goes against the basic philosophy of Free Software. Admin access to a server or mailing list is not a right, it’s a privilege and it is given to only the senior or experienced members of the project as and when required. Nothing more or less. If I make an absolute newcomer an admin of a server just because she is a female, it will be rather a discrimination against more experienced people and I don’t think it will help the project in any way.
  • All the decisions taken in Ubuntu-IN were taken as a result of a consensus among all the members of the team. You didn’t care to participate in any way and just bombarded with impractical recommendations. We repeatedly asked you to provide feedback or participate but you preferred to lurk in those times and tried to blast us with false allegations instead. No we don’t discriminate against females, but we won’t give them any special treatement either. You have to earn all the respect and privileges by virtue of your work here and not your gender.
  • Mentoring women is important, but it’s in no way more important than mentoring equally new but interested men. I personally don’t believe that *-women groups serve any practical purpose as there are many men in those lists and the same people can’t behave differently in two separate lists. The problem they say, lies between the keyboard and the chair, and nothing else. It’s just a mental block among many females which is basically an hypothesis propounded by a handful feminist women. For example, not many women applied for the Google Summer of Code, but when GNOME Foundation announced the Women’s Summer Outreach Program, hundreds of women applied for that. Considering the fact that the WSOP had < 1% scholarships available, this little piece of statistic does suggest that the problem is actually somewhere else.

So Vidya, your assumptions are mostly wrong in this matter and I don’t know what you want to achieve by condemning all the men for their so-called rude behaviour and their discrimination against women. Instead of whining about the status quo and founding more foo-women groups why don’t you join the generic foo projects and try to change the situation? I am sure everybody here is ready to accept constructive criticisms. This is the best possible thing one can do to improve the situation, splitting projects merely to separate the women from the community is, if at all, a very bad solution. That is, in my very humble opinion.

 

The coffee now smells better Mon, 03 Jul 2006 20:09:15 +0000

Filed under: Free Software, General — Baishampayan @ 20:09:15

I went to our local Cafe Coffee Day after quite a few weeks last Saturday. Then I went inside the front-desk to change a few songs and the friendly waiter Amit told me something which had the word “Linux” in it. I ignored him completely and went on to the computer desk and noticed that there were two computers now instead of one. They are doing the billing on a new HP machine and the songs are being played from the old machine. I asked the manager the secret behind the new machine and he told me “They have now upgraded the software everywhere and it now runs on Linux”. I was extremely surprised. I couldn’t believe it, so I went on to check it out myself. And indeed, Ctrl+Alt+F1 told me that they are running some flavour of GNU/Linux. The actual Java application ran on the 2nd virtual terminal. It seems they have somehow locked down the system and it boots up to start the Java app by itself. Pretty nice actually. They also have some nifty things like a 802.11 based order taking device and also a bill printer.

I am sure this is a pretty big step towards total GNU/Linux domination. This bold step by Cafe Coffee Day will help in proving that GNU/Linux is indeed ready for the enterprise.

So guys, go ahead and enjoy your coffee in Cafe Coffee Day, and be assured that your bill is being processed by a system based on Free Software :)

Cafe Coffee Day Computerised Billing System The whole thing runs on GNU/Linux :)