a blog by Marius Gedminas

All hail our robotic overlords?

Yesterday I held a G1 phone in my hands. An interesting little device. I'd buy one in a heartbeat, if I could. T-Mobile sells them only with a data plan, and T-Mobile doesn't operate in Lithuania.

Openness is the primary reason I'm interested in Android phones. I don't see how that can be compatible with operator lock-in.

On narrative doctests

Andrew Bennetts writes why narrative tests are lousy unit tests. I completely agree.

Narratives are great as documentation, and the embedded doctest sections help (1) keep the documentation up-to-date and (2) provide concrete examples that make the documentation easier to understand. Here's a good example of that: Storm ORM tutorial. But for unit tests you want many small, isolated tests rather than one big narrative, for reasons that Andrew so clearly elucidated in his post.

My preferred way of writing unit tests is a mixture of unittest and doctest:

import unittest
import doctest
from cStringIO import StringIO

from mysuperduperpackage import Gronkulator


def doctest_Gronkulator_parseXML():
    """Tests that Gronculator.parseXML does the right thing

        >>> g = Gronkulator()

    You pass a file-like object to Gronkulator's parseXML():

        >>> g.parseXML(StringIO('''
        ... <gronk id="g42">
        ...   <item id="a">One</a>
        ...   <item id="b">Two</a>
        ...   <item id="c" important="yes">Three</a>
        ... </gronk>
        ... ''')

    and the items are loaded into ``g.items``:

        >>> for item in g.items:
        ...     print item.id + ':', item.title, '!' if item.important else ''
        a: One
        b: Two
        c: Three !

    """


def doctest_Gronkulator_parseXML_error_handling()
    """..."""


def test_suite():
    return doctest.DocTestSuite(optionflags=doctest.NORMALIZE_WHITESPACE)


if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')

I've written more about this on Zope mailing lists on several occasions.

N810: death and rebirth

My beloved N810 died last Tuesday. Well, not died died, but the screen stopped working. The topmost plastic layer is fine, but the LCD is probably cracked underneath. This probably happened while I was in an Apple store watching a friend of mine buy an iPhone. Coincidence?

I ordered a new one from Amazon that evening, and it arrived on Thursday. It had the oldest possible OS2008 version (and an incorrectly-formatted internal flash card), so I had to reflash it, and then install the OS feature updates one at a time, with forced a reboot in between. Untimely breakage of extras-devel didn't help either, and neither did the broken maemo-mapper package in extras. (Both are fixed now.)

Almost all of my data was on the miniSD card (including a week-old backup). To get the rest I had to blindly get the old N810 online and open a browser page (measuring distances from the corner of the screen) to get past the hotel wireless nag screen, and then guess its IP address, so that I could ssh in.

It thought maybe I could use arping on its MAC address to get the IP, but had no luck there. It didn't respond to broadcast pings either. Finally I had to ping every IP in my subnet individually and then grep for the MAC address in my kernel's ARP cache. Oh, how I wish Maemo came with avahi-daemon preinstalled! ssh mg-n810.local would have been so much simpler!

I'll try to get the old one repaired.

Update: thp describes how to get avahi-daemon on the tablet.

Update 2: the old N810 is repaired (screen replacement cost me 510 LTL, which is ~200 USD, at the local Nokia service center). It now serves as an Internet Radio station at home.

Users and Developers

One recurring theme that I noticed during the Maemo Summit was people apologising for not being developers. A running joke during some of the talks on the first day was people describing themselves as disabled because they were not, themselves, developers.

That's just wrong. Users should not be ashamed for being users!

I'm a developer, but I often want to be just a user. I want software to just work. I wish there was no need for bug trackers. I wish users did not need to know about source packages or patches. I want to hack because I want to, not because I need to.

Until that becomes reality (if ever), I prefer the ability to make use of my developer experience to make things better. Hence my enthusiasm for open source, bug trackers, source packages and patches.