Thrift with Python on Win32


Thrift is a wonderful protocol, it’s all sum up in a single paragraph:


Thrift is a software framework for scalable cross-language services development. It combines a powerful software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, and Ruby. Thrift was developed at Facebook and released as open source.

And I really like it especially now since the system I’ve build and supporting now are written in python / c++ / ruby, these systems need to talk to each other, thrift, it’s like the answers to the prayers! : )

I have back-end systems that runs in Linux, and has client app that runs in Windows. Compiling and using thrift in Linux based system are straight forward, but unfortunately its not as easy in MS Windows platform.

At this time of writing, the code checkout from Thrift Apache Incubator still need to be further modify so that it can be compile with MSVC. These are the steps I’ve went through to get the thrift for python to build:

Ingredient:
1. Python 2.6.4
2. Visual C++ 2008 Express Edition
3. thrift-incubating-0.2.0.tar.gz
4. Windows Xp (obviously)

Read this post at http://issues.apache.org/jira/browse/THRIFT-252 to understands what needs to be edit.

Build thrift for python:
1. On Linux machine, apply the patch to the thrift source. Yes, on Linux machine, or you’ll have line ending problem.
2. Install python 2.6.4 and Visual C++ 2008 Express Edition on your Windows XP machine.
3. Copy the patched thrift source to your Windows machine, e.g: C:\tmp\thrift-0.2.0\
4. Start a command prompt and follow the following steps:

C:\> cd c:\tmp\thrift-0.2.0\lib\py\
C:\tmp\thrift-0.2.0\lib\py> python setup.py install

That’s it! Everything should compile and install to your python site-package directory. To test just do the following:

C:\> python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import thrift
>>>

No error is good news : )

I had to modify the patch by Michael Greene to fix a problem where the LITTLE_ENDIAN and BIG_ENDIAN was not define in my attempt of getting it build with MSVC9, other than that, everything else he did work marvelously, thanks! : )

Here’s the diff file that work for me, and the binary build that should work for python 2.6.4 on Windows.

just the diff file to modify fastbinary.c and setup.py
thrift-0.2.0-msvc-patch.diff

the patched source package:
thrift-0.2.0-msvc-patched.tar.gz

if you want to skip the compilation and just want to thrift right away with python 2.6.4, here’s the binary, extract and copy to C:\Python26\Lib\site-packages\
thrift-python-2.6.4-win32.zip

NOTE: Due to the source of thrift are still actively being improve, it’s best not to apply the diff to the source you’ve just check out, as it MAY have already been fix, its best to open up the related files, and read through, to make sure the patch is still needed.

Goodbye NucleusCMS.

I’ve been a happy NucleusCMS user since the beginning of me blogging years back, but the recent problem with the spam on the comment is forcing me to move to a blog engine that has better spam management interface. i.e: comment approval system… etc. Believe me, I’ve tried all the spam fighting plugins available to NucleusCMS already, but it work to an extend that I still need to manually clear out hundreds of spam message manually.

A short searching around the web shows me that wordpress seems to be a good replacement, I really like the admin interface, and it even come with import engine to convert an existing blog!

Following the guide at wordpress, with some luck, I’ve manage to get all the entry from my Nucleus blog into the newly installed wordpress : )

Some comment in blog post are missing, not sure why, and I can’t tell if this will help be combat the comment spam more effectively, but I’m still happy.

Upgrading my laptop in Starbuck

I’ve just got myself two stick of 2GB RAM and a 400GB HDD. Sat in a Starbuck, with my screw driver from my backpack and a Ubuntu 9.04 64Bit CD. 30 minutes passed and tada!!!

Yes, I did it in Starbuck ^_^

Getting Audacious2 onto your Ubuntu 9.04…

The default apt-get from 9.04 does not gives me audacious2, so, compiling it myself seems to be the only option.

1. Install the required build lib:
   $ sudo apt-get install libglib2.0-dev libgtk2.0-dev libmowgli-dev libmcs-dev libdbus-1-dev libdbus-glib-1-dev libxml2-dev libmad0-dev gstreamer0.10-fluendo-mp3 build-essential linux-headers-`uname -r` timidity

2. Download audacious2 source:
   $ wget http://redmine.atheme.org/attachments/download/69/audacious-2.0.1.tgz
   $ wget http://redmine.atheme.org/attachments/download/71/audacious-plugins-2.0.1.tgz

3. Extract and build audacious2:
   $ tar xzf audacious-2.0.1.tgz
   $ cd audacious-2.0.1
   $ ./configure
   $ make
   $ sudo make install

4. Extract and build audacious2 plug-ins:
   $ tar xzf audacious-plugins-2.0.1.tgz
   $ cd audacious-plugins-2.0.1
   $ ./configure
   $ make
   $ sudo make install

5. Install EQ presets:
   $ wget http://www.dreamcubes.com/webdrive/eq.preset
   $ mkdir ~/.config/audacious
   $ cp ./eq.preset ~/.config/audacious

That’s it!

The default installation has no equalizer presets, you’ll need to import one from WinAmp or adjust it yourself, thanks to Bryan Murdock you don’t need to : )

Do Not Tilt! or DIE!

I was holiday in Singapore, and I am surprise that, almost every vending-machine that I come across on the streets has this stickers on it that says “Vending machine design prevents dispensing free products or coins. NEVER ROCK OR TILT: Machine can fall over causing serious injury or death!

Free Upgrade on Dell D630!


I could not believe it! I’ve just got a free upgrade to a dual screen monitor on my 6 months old Dell D630 laptop! The only problem would be its unable to boot into windows anymore… Contacted the Dell support guys, apparently the motherboard has to be replace, and its back to single screen… what a bummer…

oh well… Dell Sucks… as usual…

I want pretty and I want my TitleBar!

Just got back my Compaq V3000 laptop from the dealer. Its a little over 2 years old, but it has been sent back for mother board replacement for the 3rd time! (glad that I had the extended warranty period to 3 years)

Figure that I can put Ubuntu 8.10 on it while waiting for 9.04 to come alone in about two weeks time.

Installation went well, NVidia (NVIDIA-Linux-x86_64-96.43.11-pkg2.run) driver seems to install properly as well.

Reboot and damn! Wher’s my window title bar? and also the Terminal windows is un readable as well. Turning off the visual effect seems to give me back the title bar, but that’s not the solution.

For the next 5 hours is frantic googling for solutions, and it really is funny that so many had the same problem, and offered bloody lot of suggestion that is not working, until came along this article Ubuntu Desktop Effects – Fixing the missing titlebar and it hit the right spot. Just these two lines in your /etc/X11/xorg.conf under the ‘Section “Device”‘:

Option "AddARGBVisuals" "True"
Option "AddARGBGLXVisuals" "True"

: )

Is it just me? Or is it just plain spooky ~

Ok… I went to my local mall today to catch a movie and this is what saw in one of the children fashion outlet… :-O

Aptana in Ubuntu 64bit

Installing Aptana in Ubuntu 64bit is no fun, every other distribution has its standalone package, but not on Ubuntu 64bit : (

After installed Aptana onto my Eclipse as a plugins, launching Eclipse (now with Aptana) splat me on the face with “Aptana requires Sun JRE 1.5 or greater to work properly.

But I’ve already had JRE 1.6! Some forumers says I need to update my JAVA_HOME and the symbolic link that points to the “real” JRE 1.6:

ubuntu:~$ sudo update-alternatives --config java
ubuntu:~$ echo "export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre" >> ~/.bashrc

Now there is a problem, the error is gone, only if I launch Eclipse from terminal, if I launched it from the “Main Menu”, the error about JRE comes back.

Until much later I found out that Eclipse support a flag -vm to specifically allow one to point to the VM they wish to use, I’ve added the line “/usr/bin/eclipse -vm /usr/lib/jvm/java-6-sun/jre/bin/java” as the command to execute.

So, I dont get it, why is $JAVA_HOME not set if eclipse is launch from the “Main Menu”?

My New Phone :)


The I.T called me up today and asked me to pickup my new phone from them, its a SonyErricson P1i ! ^_^

I waited I got home, and un-box the package with my washed hand ;)

Swap in my SIM card, and plugged in its battery, viola, IT’s ALIVE~

After fiddling with it for a while, I realize that it could not connect to my home wifi, which seems odd, my colleague’s N95 connected to it without any fuss…

Another problem that I found, is that I can’t get my Motorola H700 bluetooth head set to pair with my new phone.

A quick browse for solution on the www, found that plenty of people has the exact same problem as I, it is not until I found the following articles that solve both my problem:

1. Unable to connect wifi:

In most cases P1i connects to the network but the applications cannot access the web.

I had the same problem but the solution i found was to reduse the threshoud to 2346.

For this go to internet accounts /more/advanced and change RTS threshold to 2346 and powersave to OFF

now ur browser should be able to access the web.

2. Unable to pair Motorola H700

1. With the mic closed, press the call button and hold it for a few seconds.

2. When the purple (or lavender) light comes on, open immediately the mic while the light is on. After you do this, the light will flash two times and then will remain steadily lit (If the light die off after the boom was flip out, then maybe the connection of the boom is loose, so after you flip it out, FORCE it out a little further, that should make sure this steps work).

3. Your headset will be now in pairing mode.

I must say that another thing that I’m actually shock is that it does not come with a “joy-stick” like my old K700i, although I’m expected that its a “PDA” phone after all.

Now that I’m happy, the keys are still something I need to get used to, qw-er-ty keyboard on a phone… hm….