Previous Entry | Next Entry


Windmill
Originally uploaded by sfllaw.

I’ve been tilting at windmills, recently.

Windmill, actually.

It’s a Python program that lets your computer drive a web browser, without any human interference. We use it at Akoha to run tests that make sure that our website works with Firefox.

We use it to help us test our site with Internet Explorer. So I dutifully set up a Windows machine and tried to get it to run our test suite. I quickly realized that our software was going to need something more Unix-like.

Cygwin is the answer to that problem. It provides a full POSIX environment inside Windows. I built all our software and tried to fire up Windmill.

ImportError: No module named _winreg

Uh oh! Windmill needs to access the Windows Registry. According to the winreg documentation, it’s only available for Windows. Apparently, Cygwin doesn’t count as Windows. So I spent the weekend writing a library that fills in the gap.

cygwinreg allows you to read, write, and explore the Windows Registry from inside Cygwin. Whenever you want to use winreg, use cygwinreg instead.

import sys
if sys.platform == "win32":
    try:
        import winreg
    except ImportError:
        import _winreg as winreg
elif sys.platform == "cygwin":
    import cygwinreg as winreg

After I did that, I plugged it in, stepped back and ran my tests. They worked!

Download cygwinreg
or install it with
easy_install cygwinreg


Comments

( 9 comments — Leave a comment )
phrawzty
7th Apr, 2009 09:16 (UTC)
Do you mind if i ask what the level of adoption of Python in your work environment is ? What about in your personal projects ?
sfllaw
7th Apr, 2009 12:55 (UTC)
Akoha uses Python and Django as the base for its software. Of course, we’re very language agnostic, so it’s the right tool for the right job, but Python is our main language.

As for personal projects, I don’t really have time for those. :P
(Deleted comment)
sfllaw
7th Apr, 2009 12:54 (UTC)
Sadly no, I can’t make it out to CodeCon this year. :(
madamewoo
7th Apr, 2009 17:18 (UTC)
omg, this is some nerdy shit sisi!
sfllaw
8th Apr, 2009 03:13 (UTC)
You bet it is!
jbailey
7th Apr, 2009 17:38 (UTC)
I've had far better luck with Selenium and Selenium RC. The RC being nice so that you can drive the various browsers remotely.
sfllaw
8th Apr, 2009 03:16 (UTC)
Windmill is like Selenium RC, but has a much nicer interface. We looked at Selenium RC and although it’s more mature, they made some interesting design decisions that made us drop it.
evildrgo
7th Apr, 2009 22:21 (UTC)
Ho Gung Fu...
sfllaw
8th Apr, 2009 03:38 (UTC)
:)
( 9 comments — Leave a comment )