py2exe + anydbm error

So, I tried something simple yesterday adding a call to anydbm to a python program that I plan to distribute on windows with py2exe. Doing so I ran into this error:

ImportError: no dbm clone found; tried ['dbhash', 'gdbm', 'dbm',  'dumbdbm']

Turns out that the way py2exe works though it misses the dependency that anydbm has on a db module. The moral of the story is that if you want to use anydbm and py2exe you need to do something like:


import anydbm, dbhash

f = anydbm.open("dbname.db", "c")
...

Vinyl

As I write this I’m listening to Squeeze’s Argybargy which I ripped from vinyl to MP3 a while ago. After doing this with a couple of albums, Argybargy, The Pretenders Learning to Crawl, I’m really happy with the results. Vinyl ripped to MP3 sounds very good. In some cases better than CD. It’s been a good experiment but wonder if I couldn’t make things even better by upgrading my equipment. I’m using an old technics direct drive turntable with a grado cartridge and a reasonably good Denon integrated amp. I wonder how much better it would be if I upgraded to a low end Music Hall Turntable like an MMF 2.1 or a Rega RP-1 and exchanged the Denon for the Adcom Pre-Amp that’s filling in for my broken A/V amp downstairs. On the other hand I wonder how much I would use a new turntable.

Finally sat down with sqlalchemy…

I’ve been meaning to sit down and play with sqlalchemy for a while now. As an old person though my needs are a little different. Most people use the ORM model to relieve themselves of the burden of dealing with SQL database engines. This is all fine and dandy if you have the luxury of using an SQL database solely as a repository for data with permanence. However, SQL databases can do much more than that. In this vein the sqlalchemy tutorials don’t tell you much about database introspection, that is figuring out what the layout of a table is from the information available in the database. Introspection is very important to me because I frequently create tables (and contraints and triggers etc) on the database. I also have a frequent need to an SQL feature called views but that’s a story for a different day. I came up with this code:

#! /usr/bin/env python

''' ============================================================================================
Program: sqla.py -- A test of sqlalchemy's ability to introspect tables from a database.
============================================================================================ '''

from sqlalchemy import *
from sqlalchemy.orm import *

metadata = MetaData("mysql://scott:tiger@mysql.example.com/test")

workEntryMeta = Table('work_entry', metadata,
                      Column('work_entry_id', Integer, primary_key=True),
                      autoload=True, )

class WorkEntry(object):
    pass

def sqlToStr(c):
    if c is None:
        return "NULL"
    else:
        return str(c)

mapper(WorkEntry, workEntryMeta)

session = create_session()
q = session.query(WorkEntry)
entries = q.all()

headers = None
for e in entries:
    if headers is None:
        headers = [ c for c in e.__dict__.keys() if c[0] <> '_' ]
        print headers
        print "\t".join(headers)

    d = [ sqlToStr(e.__dict__[c]) for c in headers ]
    print "\t".join(d)

This creates an ORM object for the table work_entry in the current python program and grabs all the rows from the database printing each one as it goes.

iPad first impressions.

Well, my iPad showed up and I’m trying to touch type on it. I guess that I can say that so far I like it and I see a lot of potential for it. At the same time it works quite well with a keyboard. I think that for developers of the device a keyboard is going to be required kit.

Apple/Batteries

My biggest problem with the latest MacBooks is Apples insistence on selling them without user serviceable batteries. To me that means that the battery life is what it is and you can’t do anything about it. I own an older MacBook Pro with the replaceable battery. And I have a pair of batteries for the machine. What a pain in the neck it is to have two batteries. The webs advice on battery storage is to keep Li-Ion batteries in a cool place at about 40% charge. Also, under no circumstances let your battery discharge to nothing. I have two batteries because I don’t want to be stuck on a trans-continental flight with no laptop but more and more airplanes have empower and a trans-continental length flight is only 5 hours of laptop time when you add it up. The new Apples advertise a 7 hour battery life. Mine does slightly better than 5 on each battery depending on the workload. So in the past few trips I’ve never gone on to the second battery. Given all these things the Empower to Magsafe charger is probably a better investment than a second battery.

Occasionally you do find Pearls on the web.

Shout outs to Rami Ben-Ami for his templates at lady-beetle.com. The two people out there who have read this blog before know that I’ve been struggling with building Templates for Joomla for a bit of time. My biggest struggle hasn’t been html, it has been finding a template which has a high code quality. To me that means: Coded using CSS rather than tables. Coded using enough care to get the indention right.

Soviet Toys

When I was younger I read an essay that told how the leaders of Soviet Russia enforced a standard of low quality in the creation of their toys. The reason for doing this was to instill  low quality expectations from future Russian Citizens. While this was obviously a propaganda piece designed to make me think less of communist Russia, it resonates with me because I’m forced to do tech support on my son’s toys. The toy provoking this blog entry is the EA Sports Voice Command Pitching Machine. I’m going to put a new set of batteries in the thing and give it one more chance but given that it started out with new batteries in the first place I’m not holding out much hope. Now, this is in contrast to the Nintendo Wii and the Easton Junior Pitchback Elite. The problem with the Wii is that it’s made so well that he cannot unplug the Nunchuk attachment. The pitchback is a solid toy  that does one thing but does it extremely well.

Jay’s growing up in a Mac/Linux/TiVo world so when toys disappoint like this it really bugs him. When I look at his face I have to ask if we are doing our children any good when we provide them with poor quality toys. In consumer goods I believe that your choice is: cost, feature set, quality: pick two. It’s hard watching my son learn  this.

— Chris

Samsung 2333HD Dubious Easter Egg

I purchased a Samsung 2333HD Monitor to supplement/replace my 6 year old Samsung 213T. Until 30 minutes ago I would have classified this experience as disappointing. That is until I found the HDMI Easter Egg that Samsumg hid in the monitor’s firmware.

My problem is that I want to be able to use both my MacBook Pro and my Mac Mini with this monitor. And I want a full digital signal path from either computer. On the 213T that meant switching cables or sucking it up and using one computer with an Analog VGA input. The Advantage that the 2333HD has is that it takes HDMI Digital inputs. I got an HDMI  -> DVI cable and ran it to the monitor and I was surprised to see the poorest display that I’ve seen in a while. Luckily I ran across a review on the internet of the monitor that mentioned that it will change how it handles an HDMI input signal if you label it as coming from a PC. A couple of menu settings later and I’m looking at a reasonable display.

It’s nice that they set things up this way. It would have been nicer if they had documented it in the manual.