Older blog entries for pycage (starting at number 77)

"Native" PAN support for maemo

maemo in a PAN
The waiting is finally over. There is now support for phone-tethering via the PAN Bluetooth profile, which is so popular on Windows Mobile smartphones.

By "native" I mean that it's quite well built into the system and does not appear as a separate application. And you no longer need a command line or root access for making PAN connections.

After you have installed the maemo-pan add-on (sorry, only OS 2008 supported so far), you can get online with just a few simple steps:
  • Go to the system preferences and add your phone in the phone settings. Do not enter the wizard for configuring the dialup settings. PAN does not use them.

  • Start internet sharing on your phone. It depends on your phone how and where to do this. On Windows Mobile 5, open the Start menu and select "internet connection sharing" from there.

  • Make sure that Bluetooth is enabled on your internet tablet. Now open the connection dialog and you will see that there is a new connection called "Bluetooth-PAN". Select it and you will be connected to the internet via PAN.

  • When you're finished, just close the connection the usual way. Wasn't this easy? :)

Thanks go to aleksandyr for figuring out stuff and to Frantisek Dufka for writing the initial PAN connection shell script for OS 2008. Without you guys maemo-pan wouldn't have happened!

Syndicated 2008-02-26 21:56:00 (Updated 2008-02-26 22:08:09) from Martin Grimme

26 Feb 2008 (updated 11 Dec 2008 at 06:08 UTC) »

No, MediaBox Media Center is NOT developed by Nokia


Somebody at maemo.org must have thought MediaBox was a Nokia application while tagging some pages. The MediaBox entry on maemo.org/downloads is tagged with "Application developed by NOKIA". This is plain wrong!

No, I am not working for Nokia, and MediaBox Media Center is not related to Nokia in any way.

Syndicated 2008-02-26 21:11:00 (Updated 2008-12-11 05:06:13) from Martin Grimme

MediaBox once again - 0.94.2 this time

Maybe I was too quick releasing MediaBox 0.94.1 yesterday. The config reader bug which could cause hanging during startup was only partially fixed in 0.94.1. So here's release 0.94.2 with even more bug fixes hitting the maemo download servers.

Syndicated 2008-02-21 20:03:00 (Updated 2008-02-21 20:09:56) from Martin Grimme

MediaBox 0.94.1 fixing a few things

I have just released Version 0.94.1 of the MediaBox Media Center. This is a bugfix release and will help you if you experienced MediaBox 0.94 hanging on startup.

The new version also adds support for non-UTF-8 character encodings in ID3 tags, such as ISO-8859-1 and UTF-16.

Thanks to all users who reported bugs and made suggestions!

Syndicated 2008-02-20 20:15:00 (Updated 2008-02-20 20:18:08) from Martin Grimme

MediaBox 0.94 - the New Enhancements and a Big Thank You!

Thank you all for reporting bugs and giving new suggestions for MediaBox Media Center! You help me a lot making this the best and friendliest media center for the tablets! Keep on reporting; you decide what's important!

MediaBox Track Info

So here is release 0.94 with a lot of small improvements.

The media scanner will now cache already loaded thumbnails so it will be quicker after you add or remove a media folder. You can also specify for each folder which kind of media you have in there. Thus you will be able to avoid getting all your album cover art listed in the image viewer, for example.

Configuring the media collection

If you've always wanted to play the FM radio through the loudspeakers, you can do so now. MediaBox can finally switch from headphones to loudspeakers when the headphones are plugged in as FM radio antenna. The FM radio is only available on the N800, though.

The button on the Nokia headset is now also supported and you can press it to pause and resume playback.

I have also added a tag parser for FLAC tags and fixed some flaws regarding FLAC playback. FLAC is a free and lossless audio codec for high quality audio.

MediaBox is now powered by player backends for mplayer and the native osso-media-server. By selecting between two backends, more media formats can be played back. This especially adds support for real media and real internet radio streams (.ram), as well as MP4 and 3GP videos.

The new MediaBox release is available from the website as well as through the application manager in the Maemo extras catalogue. The package installs on OS 2006 (video playback not yet supported on the 770), OS 2007, and OS 2008.

Syndicated 2008-02-11 19:50:00 (Updated 2008-02-11 19:58:55) from Martin Grimme

MediaBox 0.93 with support for embedded ID3 album art and more

Maybe you have already noticed that there's now MediaBox 0.93 available in the maemo-extras repositories for OS 2007 and OS 2008.

So what's new in this release?

First of all, rendering became a bit faster. Many rendering operations are now directly performed on the X server where they run 2D-hardware-accelerated. Previously, only the kinetic scrolling was done like this. Especially the Nokia 770 gives very smooth results that way.

But much more important, the media scanner became a lot quicker. So if there are no new thumbnails to generate, it will scan your media in almost no time. Together with deferred thumbnail assembling, this greatly speeds up startup time.
The scanner is now also much more robust and knows how to get past bad media files that make mplayer hang during thumbnailing. Oh, and you can now watch the new thumbnails while they are being created.

I have improved the ID3 tag parser as well and it supports ID3 v1, v2.2, v2.3, v2.4 now. If you have album art embedded in your ID3 tags, then chances are good that MediaBox will be able to show it.

MediaBox also runs on the Nokia 770 with OS 2006, but video still does not work reliably there, and there are still some memory issues to be solved. But it's perfectly usable as a photo viewer or for playing music. Of course I'll keep testing MediaBox on the 770 and try to make it work even better.

See the release notes for more.

Syndicated 2008-01-25 18:02:00 (Updated 2008-01-25 18:13:36) from Martin Grimme

N810 - What's good, what's bad

It's been one and a half weeks since I got my N810 and I had some time to play around with most of its features.

What I like

The N810 is a bit smaller than the N800 and 770 and easily fits a jeans pocket. The size is just perfect for an internet tablet. It's tiny, reasonably thin, but still features a screen big enough for enjoying multimedia and the web.

For the first time, Nokia included a usable carrying case with an internet tablet. If you remember the "sock" that came with the 770 and the "shades sleeve" of the N800 (where the device slipped out easily), you know what's unusable. The N810 case is still a soft case, but the device won't slip out and the upper hardware keys are still accessible.
The surface and back of the device are made of brushed metal and look very noble compared to the toy-look of the N800. No other internet tablet can beat the speakers of the N800 but the tiny speakers to the left and right side of the N810 produce surprisingly good sound. The builtin stand is solid and has three positions. That's one more than the N800 has.

There is finally a hardware keyboard which can be slid out. Of course, it's not a full-size keyboard, but the keys are good to press with your thumbs. I especially like the fact that it has backlight and is thus usable in the dark. I always hate it when I can't properly see my laptop keyboard in the dark. The stickiness of the shift and Chr keys was a good idea and it makes typing reasonbly fast.
The stickiness is important because you usually don't want to hold down the shift key while pressing a letter when typing with only two thumbs. There is also a builtin GPS receiver together with preinstalled map software.

The map software is simply a light version of the Navicore / Wayfinder navigation software. If you have a valid Navicore or Wayfinder license, you can unlock the navigation functions of the map software. As a 770-Navicore user I simply entered my key and, hey presto, I had the current Navicore (which is now called Wayfinder, since they bought Navicore) installed on the N810.
Luckily, the N810 comes with the appropriate car holder. When I got the N800 I was annoyed by the fact that it didn't fit the car holder from my 770-Navicore.
Some people reported problems with the GPS receiver, but I got a GPS fix rather quickly even on a totally foggy dark winter morning.

I also want to point out that the new OS 2008 seems to be very stable and I didn't experience a single crash so far! It's also nice that you can now lock the screen and keys with a hardware key. Very handy!

What I don't like

Of course the N810 isn't perfect. Here's my rant.

Who designed the carrying case? It looks as if I was carrying a medical device around. The look just does not fit a high-tech internet device! I hate the size of miniSD cards (and even more so the size of microSD!).
My card readers and the N800 take full-size SD cards. Whenever I want to put a miniSD card into my N800 or the card reader, I have to fiddle with an awkward adapter. Totally annoying! The micro-USB port is also annoying because now I have an extra cable attached to my computer.

The car holder has a big bulk of plastic on the top. This was totally unnecessary and I might eventually cut off this part. While I understand that the device leaves no place for cursor keys anymore, I find it bothersome to pull out the keyboard everytime I want to use the cursor keys or the center button.

The map software lets you download new maps off the internet, but this never worked for me. Not on my N800 and not on my N810. The Wayfinder download server must be seriously broken as many users report problems downloading maps. The included map of Germany & Alps (2008) shows no difference to the map update of Navicore (2007) or the map included with Navicore (2006). And even the 2006 map wasn't up to date then. I still miss major roads built in 2006 on the 2008 map! For example, look at the B2 between Donauwoerth and Augsburg. The parts built in 2006 are still missing!
And the map has bugs, too. For example, it shows Technische Universitaet Munich in a totally different town. Not to mention some POIs to be placed wrongly. I have no navi to compare, but I suspect that all navis using Teleatlas maps have the same problems.

The new MicroB web browser shows very buggy behaviour when panning with the stylus. Sometimes it works, sometimes it jumps nervously around, sometimes it just selects text. The browser is also a bit slower than Opera on the N800 used to be.

The position of the light sensor is also not optimal as it's too easy to cover it with your fingers while holding the tablet.

Syndicated 2008-01-20 21:32:00 (Updated 2008-01-20 21:46:19) from Martin Grimme

1 Jan 2008 (updated 11 Dec 2008 at 06:08 UTC) »

Tablet Python #3 - List Comprehension

A Happy New Year to everyone! In today's episode of Tablet Python I'm going to tell you more about list comprehension which we were already using in the last episode.

Introduction

List comprehension is a unique feature of the Python language (correct me if I'm wrong). It might look intimidating at first, but believe me, it can soon become one of your best friends in Python. It's so elegant and simple!

But let's approach this step by step.

Step 1: You can copy lists

Let's define a list

a = [1, 2, 3]

You can make a copy of a by iterating through the elements in a, like this:
copy_of_a = []
for element in a:
copy_of_a.append(element)

This is about the way you would do it in any other language. But with list comprehension, you would simply write:
copy_of_a = [ element for element in a ]

This simply says, build a list and for every element in a, put element into this list. Then assign the new list to the variable copy_of_a.

For completeness, I want to tell you, however, that the easiest way to copy a list in Python goes by "slicing":copy_of_a = a[:]

Step 2: You can build modified copies

Let's assume you have a list of filesystem paths and would like to strip off the path so that only the filename remains.

This is our list:
a = ["/home/user/file1", "/media/mmc1/file2", "/media/mmc2/file3"]

And this is what we want to get:
["file1", "file2", "file3"]

The classic way goes like this:
b = []
for element in a:
b.append(os.path.basename(element))

But with list comprehension, you'd do it like this:
b = [ os.path.basename(element) for element in a ]

Or in words: build a list, and for every element in a, apply os.path.basename() on element and put the result into the new list. Then assign the new list to the variable b.

Step 3: You can filter lists

Now let's take a look at the list comprehension construct from the last episode:
resources = [ f for f in os.listdir(_RESOURCE_PATH) if f.endswith(".png") ]

Can you guess what it does?
Build a list, and for every f in the result of os.listdir(_RESOURCE_PATH), put f into the new list if f.endswith(".png") returns True. Then assign the new list to the variable resources.
It's the same as:
resources = []
for f in os.listdir(_RESOURCE_PATH):
if f.endswith(".png"):
resources.append(f)

... but way shorter, less error-prone, and easier to read!

Step 4: You can combine modifying and filtering

Let's take this to the extreme by modifying and filtering a list at the same time:
a = [ str(c) for c in range(100) if (c % 5 == 0) ]

This builds a list a which contains as strings those numbers in the range between 0 and 99, which can be divided by 5.
This would be
a = []
for c in range(100):
if (c % 5 == 0):
a.append(str(c))

for all those poor people who cannot use list comprehension.

Step 5: Still confused? It's simply a mathematical set notation!

Do you remember this notation?

List comprehension in Python is just the same!
B = [ x*x for x in A if (x % 5 == 0) ]

And that's the secret key which helps you understand it.

Conclusion

Generally, list comprehension helps you write cleaner code. It expresses how you think about solving the problem instead of describing every step necessary to solve the problem. Once you get used to it, it's a much more intuitive way of working with lists.
A feature of higher-level (functional) languages is that you can make the computer solve problems by describing what you want, instead of giving step-by-step instructions on how to solve it.
However, as with every powerful tool, use it wisely. It's e.g. generally not a good idea to use list comprehension to shorten code with side-effects. Don't use list comprehension to make your code shorter, but to make it understandable.

Syndicated 2008-01-01 15:14:00 (Updated 2008-12-11 05:06:13) from Martin Grimme

Tablet Python #2 - Resource Modules

Introduction

In this second episode of Tablet Python, I'm going to tell you about an easy way to make resource modules. A resource module is a Python module which you can import for loading resources such as images, fonts, or whatever you want.

For example:

import graphics

img = gtk.Image()
img.set_from_pixbuf(graphics.icon)


Implementation

In episode #1 we talked about writing relocatable software. We are going to apply the same technique for resource modules, since they will be relocatable as well.

Our resource modules are Python packages, i.e. a subdirectory with a __init__.py file in it. The name of the directory will be the module's name. Be careful to only use valid characters (characters valid for Python variables) in the directory name and the filenames of the resource files (e.g., my_icon.png is OK, while my-icon.png would be not!).

Let's assume the following filesystem structure for our example:

graphics/
+ __init__.py
+ icon.png
+ logo.png
+ background.png

test.py

The package directory will also contain the resource files. In order to access them, we'll have to put them into the module namespace. Write the following into graphics/__init__.py:

import os
import gtk

_RESOURCE_PATH = os.path.dirname(__file__)

def _load_resources():

# Find all .png files in the resource directory. This construct is called
# "list comprehension" and will be covered in detail in episode #3.
# This returns a list of the names of all files in the resource directory
# ending with ".png".
resources = [ f for f in os.listdir(_RESOURCE_PATH)
if f.endswith(".png") ]

# load resources into module namespace
for r in resources:

# the filename without extension will be the name to access the
# resource, so we strip off the extension
name = os.path.splitext(r)[0]

# this is the full path to the resource file
path = os.path.join(_RESOURCE_PATH, r)

# Now we can load the resource into the module namespace.
# globals() gives us the dictionary of the module-global variables,
# and we can easily extend it by assigning new keys.
globals()[name] = gtk.gdk.pixbuf_new_from_file(path)

#end for

# load the resources when importing the module
_load_resources()

That's all. Let's test it with a tiny test program test.py:

import gtk
import graphics

win = gtk.Window(gtk.WINDOW_TOPLEVEL)
img = gtk.Image()
img.set_from_pixbuf(graphics.logo)
win.add(img)
win.show_all()

gtk.main()

You may put as many resource files as you want into the resource directory and simply access them by their name. The files are loaded only once when the module gets imported the first time. Subsequent import statements reuse the module without reloading the resources. I'm going to talk about the "singleton" nature of Python modules in a later episode.

A more sophisticated example of resource modules can be found in the theming engine of MediaBox (the subdirectory called theme).

Syndicated 2007-12-30 13:31:00 (Updated 2007-12-30 13:41:59) from Martin Grimme

MediaBox doesn't like winter?

There crawled a stupid little bug into MediaBox which made it dislike winter. A bug in the clock module made it return bogus data during winter. Since winter started recently, MediaBox failed to start up after December 22nd.

clock

The new release 0.92.1 fixes this. Now you can enjoy MediaBox again!


Merry Christmas!

Syndicated 2007-12-24 15:09:00 (Updated 2007-12-24 15:15:21) from Martin Grimme

68 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!