Present Perfect


Picture Gallery
Present Perfect

Python Packaging

Filed under: Hacking,Python — Thomas @ 20:11


Lots of rpms of python software have the wrong "file path" compiled into their byte-compiled versions. So when you get tracbacks, you see stuff like '/usr/src/rpm/BUILD' or similar in the paths of the installed python file. I've run into this for several packages, but was too lazy to look at it.

Today we ran into a similar issue with our server; Johan was doing some magic to transmit code on the fly but it got the path wrong. This is because during a build files get installed in a staging area. It's this location that gets stored during byte-compiling.

Luckily the fix was easy; I added a --destdir option to a custom py-compile, and then override py_compile which luckily worked out fine.

I should probably push this upstream to automake; any packagers/python hackers who are willing to test this and give me some feedback on it ?

Server Hacking

Filed under: Fluendo — Thomas @ 02:10


Today was weird bug day. I spent four hours trying to fix a bug that I could not understand at all. It seemed like python and twisted were somehow turning a string into a tuple at some point and I couldn't figure out where. Of course it was a silly bug in the code that went something like this:

keycard.requesterName = componentName,

Python programmers will see the trailing comma and realize that this makes the member a tuple, and not a string as I wanted.

I didn't find the bug easily because I debugged using something like

self.debug('keycard requested by %s' % keycard.requesterName)

which has the generally wanted side effect of just printing the only member in the tuple. So debugging like this makes it look like a string !
However, when you print with two variables:

self.debug('authenticating keycard with id %s for %s' % (keycard.id, keycard.requesterName))

it did show up as a tuple !

Maddening. One of those instances where you finally understand some little line of text in a python manual you read some day.

The second bug was more mystifying. I was debugging authentication using a special component, and when testing it out, all lengths of username/password worked in the HTTP request, except for the ones that had 3 characters for both username and password, which turned the username and password on the server side into empty strings. Totally incredible - dad/mom turned into empty strings, while dad/momm, dad/mo, dad/mommy, daddy/mom, da/mom, and all other combinations worked. I was so floored by this that I didn't even try to look into the bug, and just changed the password's length and get it over with.

Also, my very handy debug cycle of "change code-click reload-try new code" is completely trashed on three levels today. First of all, twisted's rebuild doesn't work as it did anymore, with python complaining about all sorts of issues when objects get rebuild. Second, pychecker doesn't work on dotted imports for some reason when used through the import mechanism. And we need to use the import way because we modify a module's __path__ to bring together different paths containing the same package layout. And third, when restarting a worker, something doesn't get cleaned up correctly, causing bind to return with an "Address already in use". So my debug cycle now consists of "change code - stop worker - restart - repeat five times until it doesn't show a bind error".

At that point you get into a lot of wasted time because you are really working on writing some new code, when you should just stop and fix either of these three issues allowing you to work faster on the actual code.

Anyway, the special authentication component is finished and works well. I created Python bindings for SQuaLe yesterday, then used them from the component. A query gets run every 30 seconds for each client, and when that query returns false the client gets expired. Neat stuff.

We're finally getting to the point where we can just write new components and use them pretty quickly. It's nice to see a good foundation pay off.

On How Life Is

Filed under: General — Thomas @ 01:59


We've been here for almost a year now. I had a long period where I didn't wonder about the fact that we live somewhere else for the last few months, but now the sense of wonder is back.

Yesterday we went to some Mexican restaurant to celebrate David's birthday. While riding my bike to the meeting point, someone called out to me on the street. Being called out to is something that hasn't happened to me for a year, and that's something you don't realize or think about until it happens. Pretty damn cool to actually know some people here that try to stop you in the streets :)

The Mexican food was great, and since some of the gang had their birthday coming up as well, we agreed to have a party at our place in two weeks with the Mexican guy cooking. And I already reserved my place in the kitchen to watch and help...

Today while driving home I got run into by a girl on a moped who was of course speeding through the red light as soon as the green pedestrian light started blinking. She turned right while looking left for oncoming cars and crashed straight into me. Spanish people have a weird sense of traficness. Having this happen is another confirmation that I really do live here though.

We went to a bar where we had arranged to meet with an Argentinan giving tango classes. Kristien has never had classes, so we decided to take a few private lessons and then jump into a real class. He was quite a good teacher, even though his accent is hard to understand. And it's disorienting for me to do exercises as the woman, but it's good practice for my general understanding.

After that we went to an intercambio in a Belgian bar which was nice as well. Meet some new people, marvel at all the Belgianness, and feel at home. So, basically, after a year of cocooning and adapting to the idea that we're here, we're now sculpting our place in the city. It's like learning to walk all over again, and it's great.

« Previous Page