While trying to run our tests in a clean virtualenv (–no-site-packages), psycopg2 (tried both 2.0.13 and 2.0.14) can not be imported with a error traceback like the following:

File "....py", line .., in
  import psycopg2
  File "build/bdist.linux-i686/egg/psycopg2/__init__.py", line 69, in
  File "build/bdist.linux-i686/egg/psycopg2/_psycopg.py", line 7, in
  File "build/bdist.linux-i686/egg/psycopg2/_psycopg.py", line 6, in __bootstrap__
ImportError: can't import mx.DateTime module

However, search python source files in the install psycopg2 package does not yeild any hits on mx, so my conclude was that it’s being imported in the psycopg2 c library.

It becomes clear after I took a look at the setup.py in the source tarball of psycopg2: while building the package, the setup.py will check whether it can find mx header files under the python include dir. If it can, it would just compile in the above import line into its c library. I don’t see any way it can be disabled given you have egenix-mx-base header files installed (even if you don’t have mx python module available, it will still compile in mx.DateTime support)

This would only happen if you have the egenix-mx-base header files install in the global python installation.

One workaround I came up with is to copy over the mx dir under site-packages from the global python installation into the virtualenv environment I am using to do test. Alternatively, don’t install the header files for egenix-mx-base (although in gentoo, that means you have to manually remove the header files). For now, I settled on the former workaround.

I have a USB camera I want to use with Skype to make video calls. The camera has the following lsusb output:

Bus 004 Device 002: ID 0471:0328 Philips SPC 700NC PC Camera

My gentoo is 64bit, using multilib (has 32bit libraries as well). After fiddling with Google to find the proper linux kernel driver for a while, I found a useful website  Linux Kernel Driver DataBase (LKDDb) (the kernel module is called CONFIG_USB_GSPCA_SONIXJ). After installing the kernel driver, reboot, Skype can detect a camera device /dev/video0, but when clicking the test button, nothing show up (the light on the camera comes on briefly then turns off). Further google leads me to this solution: Edit /usr/bin/skype, add the following line before the last line (exec ./skype "$@"):

export LD_PRELOAD=/usr/lib32/libv4l/v4l2convert.so

skype is a pre-built 32-bit binary, so I have to specify the lib32 explicitly above. Note: if you receive any of the following errors:

ERROR: ld.so: object '/usr/lib32/libv4l/v4l1compat.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib64/libv4l/v4l1compat.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib32/libv4l/v4l2convert.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib64/libv4l/v4l2convert.so' from LD_PRELOAD cannot be preloaded: ignored.

You are probably trying to set LD_PRELOAD on a shell script (the /usr/bin/skype is actually a shell wrapper around /opt/skype/skype, the real binary), so the following would lead to one of the above errors:

LD_PRELOAD=/usr/lib32/libv4l/v4l2convert.so skype

Try to add that line to the script instead as suggested above.

I have been seeing “setting a property that has only a getter error” poping up in my firebug for a while, which I believed was a Firefox extension conflict with new version of firebug.

A recent post to dojo-interest mailing list caught my eye: basically, a user can reproduce this problem by just loading dojo from google CDN.

I decided to take a look at this and try to figure out why.

A firebug bug report is filed about this error: with FireFox>3.5.2, modifying window.console (or attributes on console) would trigger this error. However, in the test case mentioned in the post, even if dojo is not loaded, the error still pops up in firebug, so it must be in some firefox extension, rather than dojo.

The only other extension I have in my development firefox profile is Selenium-IDE 1.0.4. Disabling it, and the error immediately goes away. Searching selenium-ide bug report, it turns out it has just been fixed in Selenium-IDE 1.0.5 (direct link to the xpi file).

In a summary, if you are getting “setting a property that has only a getter error” Error in FF 3.6 with any page, make sure you have at least Selenium-IDE 1.0.5. If you don’t use it, then you are probably messing around with window.console. (the error message would be much more helpful if it states what property is being accessed)

Over the weekends, I spent some time on Dojo Objective Harness (DOH) to fix a reported bug: in some cases the global progress bar overshoots 100%. This is obvious in the dojo test suite, the progress bar goes beyond 900%.

After some digging, it turns out the algorithm to calculate the global progress bar has a flawed assumption: the number of tests in each group is known before the tests start. That’s not the case if nested test suites are used, such as the case in dojo._base.test.

The fix is quite simple as well: rather than trying to create a portion in the global progressbar for each test, we only create one for each group.

Another problem noted in the original bug report is overflow of test group progressbar. I never noticed it before, but keeping a close eye on each group progressbar when running dojo test suite does reveal it. By removing tests in the dojo test suite, I isolated the problem to dojo.date and dojo.date. The problem is the test group progress bar is not updated at all due to the fact that they don’t have a html page (instead both dojo.date and dojo.data test cases only use javascript files). The fix for this turns out to be quite straghtforward as well as soon as I know what causes it.

After the bug fixes, I feel like to add a new feature to DOH, clickable test cases which will hilight the relevant log line after the test finishes. Searching a failture/error in the log pane is a real pain especially if you have lots of tests generating huge number of messages. The log line will be hilighted according to whether the test failed or succeeded. (Note: the hilighting requires dojo, so if DOH is used without dojo, you won’t be able to see the hilighting animation.)

Similarly, when clicking on the global progressbar, the test group associated with that portion of the bar will be scrolled into view (for any failed test group, a tooltip is also attached to the global progressbar portion to indicate which test group it is). This is useful when locating a failed test group.

In addition, a tfoot is added to the test list table after all tests finish, which contains a summary of the test run. Check out the online demo in our nightly. This will be part of dojo 1.3 release.

Apparently, google maps has different features/capacities based on different user interface languages. My parents just complained to me that they can’t find “place of interests” in their google maps any more. After obtaining more information from them, it appears that they are actually using Chinese version of google maps, while when they were using the English version, “place of interests” was indeed visible as an option.

So the problem is how to change the UI language. The website URL for the Chinese version of google maps is the same as the English version, both of which is maps.google.com, so must be another way of doing it. Searching the UI, I can’t find a control to change language anywhere. However, I did notice on one page when clicking around, where I have this in my address bar.

http://maps.google.com/maps/mm?hl=en

by chaning it to:

http://maps.google.com/maps/mm?hl=zh-CN

As expected, I get Simplified Chinese version of google maps. So to switch UI language in gmap is to append “?hl=LANG_CODE” to the URL, such as:

http://maps.google.com/?hl=en

Will load the gmap front page in English. Some LANG_CODE I tried which are recognized by gmap is: de, en, fr, ko, ja, ru, zh-CN and zh-TW. (See language identifier for a complete list)

It is well known that Firefox (even the latest 3.x) does not support text-decoration=”underline” on text elements in SVG. However, it bites me hard when I found out imagemagick does not support that either when rastering svg to pixel images.

After digging around, (by looking at the ebuild file) I found out that imagemagick is actually making use of librsvg to do the heavy lifting when dealing with svg files.

librsvg is part of gnome-base packages (as can be seen in gentoo portage). Looking at the source code, I figured that it makes use of pango to render text.

From the days of working on SCIM project, I know for sure that pango is more than capable of rendering text with underlines. So there must be something missing in librsvg to render it. It turns out that, while the svg parser implemented in librsvg does indeed look for text-decoration, and recoganize underline (among strikethrough and overline), it is not actually making use of these parsed info to render the text.

After a bit of tracing the code, I found out how to patch it: the trick is just to add a pango underline attribute to the text layout, and everything else is taken care of by pango.

This bug is reported to upstream, and hopefully it will be merged there soon. The patch is available in that bug report, so you can grab it if you can’t wait. The patch also fixes a bug which is discovered after the underline problem is fixed: when a underlined text has stroke set, the stroke is rendered in wrong position.

In a desktop environmen, menus (be it context menu or menu in menubar) have a column which display the accelerator key (or shortcut key in windows). In the 0.4 dojo Menu widget, we used to have that support, but it was not ported to 1.x.

After seeing Bill’s commit to add a real MenuBar to dijit, I think it’s the time to bring back this feature. For now, see the test_Menu.html test file for a demo.

A new property is introduced for dijit.MenuItem, called accelKey, of type String. It can be set either in markup or in the arguments passed to the dijit.MenuItem constructor (the demo contains examples for both of them). In addition, dynamically setting it is also supported, such as:

//item is a dijit.MenuItem object
item.attr("accelKey","Ctrl+W");

As mentioned in the demo, this accelKey is only a string, you can basically pass in any string you want. However, when the combination is pressed, it won’t actually trigger the action associated with the menu item: that has to be done explicitly elsewhere (such as dojo.connect to body’s onkeydown event, and detect whether a recognized accelerator key is pressed, if so, invoke the corresponding event handler).

By default, dijit.form.DropDownButton requires a dropdown menu specified when initializating. However, with a little bit of patching via subclassing it, we can easily achieve lazy loading of the dropdown menu: only creating it the first time a user clicks on the button. This will speed up the initial loading time of the application, especially if a lot of these type of buttons are present on the page.

Here is the core of how to achieve lazy loading:

dojo.declare("MyDropDownButton", dijit.form.DropDownButton, {
	dropDown:1,
	_openDropDown: function(){
		if(this.dropDown===1){
			this.dropDown=new dijit.Menu();
			var items=[{label:'One'}, {label:'Two'}, {label:'Three'}];
			dojo.forEach(items,function(args){
				this.dropDown.addChild(new dijit.MenuItem(args));    
			},this);
		}
		this.inherited(arguments);
	}
});

The trick here is to set dropDown to something which evaluates to true so that when clicked the first time, DropDownButton will proceed to call _openDropDown, where we have a chance to create the real dijit.Menu we want to show. Without line 2 above, _openDropDown won’t be called because DropDownButton thinks there is no attached dropdown menu.

As you may have already figured, in order to use this, the Menu has to be created programmatically.

While trying to add setting clipboard content support to doh.robot, I encountered a very strange bug and spent several hours of trail and failure without going anywhere. I am using java 1.6 update 11 directly from Sun. Basically, I have two problems both of which are described here: copying HTML data to windows clipboard from java does not work, with the following symptoms

  1. when puting data into the clipboard with a RepresentationClass other than java.lang.String does not work properly with any applications (it is the same issue as described in a java bug report, which is supposed to be fixed in java 1.6 update 11)
  2. even if you do use java.lang.String as RepresentationClass, the pasted html only appear correctly in IE, not in safari (it contains extra garbage characters), nor in FF (nothing is pasted at all).

The problem as described in the mentioned webpage, is due to buggy support of windows HTML clipboard format in java. One workaround is suggested in the same article by modifying some internal stuffs in the supporting class in java with the source files available for download. However, the provided code fails to run against my java 1.6 (although it does compile fine), probably due to changed internal mechanisms.

(more…)

Due to better 64bit support, we decided to use VMWare instead of VirtualBox. To prevent of installing a gentoo to a VMWare image, I decided to convert the already working virtualbox image (a vdi file) to VMWare (vmdk). Qemu-img is the command line tool for this task, using the following line, I can get a vmdk:
qemu-img convert -O vmdk gentoo32.vdi gentoo32.vmdk
However, this vmdk is not recognized by VMWare 6.5. I guess it has something to do with the fact that the original vdi file is using dynamic sizing (the file contains a 5G partition, and it only has 1.9G data, so the real size for the vdi file is about 2.1G): the converted vmdk is 1.9G, and VMWare reports that it has 2.1G total size.When booting with this image, VMWare fails to read any data from the virtual disk. After tried another time with the above approach, which also failed, it seems I have to find another way. Luckily, VirtualBox comes with a command line tool called vboxmanage, which can do all sorts of operations on vdi files, including converting vdi to raw disk image, so let’s try that:
vboxmanage internalcommands converttoraw gentoo32.vdi gentoo32.raw
The above command will generate a 5G gentoo32.raw file. Then use qemu-img:
qemu-img convert -O vmdk gentoo32.raw gentoo32.vmdk
To convert the raw file to vmdk. The resulting vmdk file is also 1.9G, but this time VMWare recognize it just fine (reporting its real size as 5G). After changing the root device from /dev/sda1 to /dev/hda1, this image can boot just fine in VMWare, with one exception: the network interface eth0 can not be started. More inspecting reveals that “udev renames network interface eth0 to eth1″. This is caused by the fact that one of the default gentoo udev rule (/etc/udev/rules.d/75-persistent-net-generator.rules) will write another rule file which saves the MAC address for each NIC, and sure enough, the MAC address for the NIC in VirtualBox is different from that of VMWare. However, this is very easy to fix, once you know where the generated udev rule is: Open /etc/udev/rules.d/70-persistent-net.rules and remove all rules in this file, save and reboot, eth0 won’t be renamed to eth1 any more.

Next Page »