cygwinreg: Windows registry access for the Cygwin toolkit


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