Headed to PyCon 2007 and My Twisted BoF Announcement

February 20,2007

Since there seems to be virtually nothing Twisted or Nevow related going on at PyCon, I thought (last minute I know) that I would at least try to organize a BoF meeting (most likely pretty informal) for folks into Twisted and Nevow. So if you are interested, please add your name to the wiki page for the Twisted BoF. If there's at least 3 or 4 folks, I'll try to setup a time, even if it's a dinner or lunch or something. Or if someone else wants to suggest a time that would be great as well.

Technorati Tags: pycon2007, python, twisted, nevow
posted by ScW @ 02/20/2007 12:08:15 PM [permalink] [comments 0]

Brandon's Handy Komodo Hacks

February 14,2007

If you're running or thinking of running Komodo Edit 4.0 (or IDE), then you need to check out Brandon's Site. In particular he's done several different tips including:
  • Find References (using Bicycle Repair Man -- BRM)
  • Extract Method (another BRM-related macro)
  • Rename Occurrences (more BRM fun)
  • Integrating Pylint
  • Improving Python Help in Windows
  • Explore Project Directory
Enjoy!

Technorati Tags: komodo, python
posted by ScW @ 02/14/2007 09:07:29 PM [permalink] [comments 0]

Running OpenSUSE 10.2 as a VMWare Guest

February 11,2007

I downloaded the 10.2 version (DVD image) of OpenSUSE just to see what it was like. I quickly created a blank 20GB virtual machine for it to install into. And then it all came to a halt. After a ton of searching, I discovered that the secret was to type "nomce" as the lone boot option before selecting "Install" from the menu. Once I did that, it installed without any problems.

As for OpenSUSE itself. It was interesting seeing such a different take on an install process compared to Ubuntu (now that I have done so many installs). I have only played with it for a few minutes but I found it interesting that Python 2.5 was the default version installed. I also couldn't immediately figure out how you're supposed to install something like wxpython on there. I'm thinking Ubuntu has me pretty spoiled. But I still think it's appropriate to give OpenSUSE a look.
posted by ScW @ 02/11/2007 01:28:26 AM [permalink] [comments 0]

pyodbc and mxODBC and Accessing the DB/400 AS/400 DB2 Databases

February 09,2007

For a utility we are writing at work we needed to be able to insert and delete records from a temporary flat file/table on our AS/400. For reference, we are connecting via IBM's iSeries Access ODBC drivers. The SELECT statements were working fine but we were getting the infamous SQL7008 errors on all DELETE and INSERT statements. I hunted frantically for a solution and everything of course explains that unjournaled files on an AS/400 won't support transactions and that the driver should be set to an isolation level of 0. The problem is that there appears to be no way to actually set something called an "isolation level" within the IBM driver.

After some experimentation and a little logic, I discovered that the solution is rather simple. In mxODBC you need to specify the clear_auto_commit=0 as part of the connection parameters. And the solution for pyodbc is similar, you need to specify the new autocommit=True as a named parameter for the connect method. The tricky part about the pyodbc is that the new autocommit parameter didn't exist until February 1st, 2007 (version 2.0.33). I was floundering along in version 2.0.30 and was stuck as to why the documentation didn't seem to match the actual library. After a quick download and install of the latest version, I was in business. It's nice to see the pyodbc project maturing and being so actively developed.

Technorati Tags: python, pyodbc, mxodbc, AS/400, DB/400, DB2
posted by ScW @ 02/09/2007 05:48:32 PM [permalink] [comments 0]

Now on wxPython 2.8.x Upgrade from 2.7.x and 2.6.x

January 29,2007

At work, I have a couple of apps we're about to release that use py2exe and wxPython. And like many folks, I've ended up seeing the zipextimporter error trying to run the final .exe on a Windows 2000 box. Windows XP was fine. I was getting this error with a wxPython 2.7.x configuration. Since 2.8.1.x is now out, I figured I'd upgrade while I was at it. Now, my previously mentioned issue with the StaticBoxSizer is fixed so that's definitely an improvement and I no longer have to use the --dell-exclude gdiplus.dll fix (yea!) , but I was still getting the zipextimporter error on _core_. Any search on google will turn up tons of hits for this error. Each time, folks are implored to include gdiplus.dll and stuff like that. No matter what advice I followed, it didn't seem to work. But it turns out the missing file was really MSVCP71.DLL (rather than MSVCR71.DLL). By including that .DLL (you can get it from the wx library area referenced in the output of py2exe) with my .exe I'm suddenly good to go on Window 2K boxes. Under XP, everything is fine without it because it is presumably already installed on an XP box. Since I was having trouble finding info on it, I figured I'd blog about it. Essentially, it's one of those things where you really need to just look at the output of py2exe because the bindings and includes for wxpython are now pretty darn accurate. Overall, a big thumbs up to wxPython 2.8.x so far. Now, I'm anxious to look at other areas to see what all is new/better.

Technorati Tags: python, wxpython, py2exe
posted by ScW @ 01/29/2007 02:17:42 PM [permalink] [comments 5]

My wxPython 2.7.x Upgrade From 2.6.x

December 13,2006

I'm not sure exactly why I did it. I decided to install wxPython 2.7.x on my WinXP development environment. Several things to note about the changes:
  • py2exe will start throwing errors (although the latest and greatest is supposed to fix it) about gdiplus.dll not being found. The solution is to use the --dll-exclude gdiplus.dll option to prevent getting the error message. This also means that you need to make sure that the Win2K machines that you deploy to already have the Win2K gdiplus.dll already installed or that you distribute an appropriate version with your code. I'm still needing to test this out.
  • I had a text control (a search field) for which I was looking for the ENTER key (via Bind on wx.EVT_KeyUp) so that I could launch an action immediately when the user pressed enter (after filling the search field). In wxPython 2.7, the behavior (at least in windows) is to now advance to the next field (like a TAB key was pressed) on using the ENTER key in a single line text control. The solution is fairly simple: just include style=wx.TE_PROCESS_ENTER in your init parameters for the text control and the control can start getting the ENTER keys again.
  • I also had registered the ESCAPE key as a hot key for a button (a cancel button) on a form. In 2.6.x, it worked fine. In 2.7.x, the escape key seems to be unavailable as a hot key for a control. Instead, I registered a handler for a CHAR_HOOK event for the whole form and look for the escape there. This has the disadvantage that you sometimes can get several events for the same key press. But at least you can get it. The code in the __init for the form looks something like this:
            self.Bind(wx.EVT_CHAR_HOOK,self._onKey)
    
    Then later on, we define self._onKey something like this:
        def _onKey(self,evt):
            if evt.GetKeyCode() in [wx.WXK_ESCAPE]:
                self.handler.handleCancelButton(evt)
            else:
                evt.Skip()
    
  • I am now having an issue with a StaticBoxSizer not properly expanding to fill its space. I am still researching this issue but it clearly is related to the upgrade since it was working correctly before.


Technorati Tags: python, wxpython, py2exe
posted by ScW @ 12/13/2006 04:02:45 PM [permalink] [comments 0]

Python and win32: Bring a Window to Front or Top

December 08,2006

Oh joy! I had the need to bring a window (other than my own program) to the front or top, even if it was minimized. So after looking around for awhile, I pieced together several different things and managed to accomplish what I needed with the following code:
import win32api
import win32con
import win32gui

def windowEnumerationHandler(hwnd, resultList):
    '''Pass to win32gui.EnumWindows() to generate list of window handle, window text tuples.'''
    resultList.append((hwnd, win32gui.GetWindowText(hwnd)))

def bringToFront(windowText):
    topWindows = []
    win32gui.EnumWindows(windowEnumerationHandler, topWindows)
    print len(topWindows)
    for i in topWindows:
        if i[1] and windowText.lower() in i[1].lower():
            print i[1]
            win32gui.ShowWindow(i[0],5)
            win32gui.SetForegroundWindow(i[0])
The important stuff here is the callback function and the win32 calls. Also note that it appears that we need both the ShowWindow call and the SetForegroundWindow call. The ShowWindow handles minimized windows and the SetForegroundWindow call pulls it it to the top. I'll be the first to admit this isn't really good code. There are other ways of getting window handles. This just happens to be the method that I got to work.
posted by ScW @ 12/08/2006 04:11:58 PM [permalink] [comments 0]

The SW Journal and My Shattered Dream

December 01,2006

I was very nearly ready to release my Python-based Snowy Woods Journal application. It's a simple application. It allows you to keep a personal journal. It's wxPython-based so it enjoys some cross-platform goodness. It uses SQLite for storage so it's pretty tight on the storage side of things. I also have support for tagging and text based searches.

I also am missing some things that would be nice like storing rich text (in a non-RTF way), export templates (although it does support a basic text export) and storing links to web-sites. I'd also like to find an elegant way to handle encryption without totally breaking the search functionality.

But aside from the encryption issue, I've found what is surely a better program for accomplishing what my little Snowy Woods app hoped to do: TiddlyWiki. And really TiddlyWiki does so much more.

In my own words, TiddlyWiki is wiki software written entirely using JavaScript embedded in an html file. It's capable of updating itself on most any modern browser. So what you have is a wiki stored entirely inside a single html file that can update itself and can be run on almost any computer with a modern browser. Furthermore, the author has made the system pluggable so new features can be added. It takes a bit of adjusting to get the hang of it, but it really is an amazing JavaScript accomplishment and for what I would use it for, I suspect that it might do just as well or better than my journal program. Plus, I could use it on far more computers. So just like my goal with my journal app, TiddlyWiki works perfectly from a little USB drive. Oh, and when it saves, it also makes a backup copy. But of course unlike most programs, the backup essentially includes the source code as well as the data.

If there's one complaint I have, it's that it does store everything in the one file. There's something that makes me nervous when my data and source code all live together in the same file. It violates every rule of common-sense abstraction I like to follow. But in the end, it still is a brilliant program that has to have many scratching their heads wondering why they hadn't thought of it first.

As for Snowy Woods Journal, I guess I'll try to finish up a few things on it and go ahead and release it here on the site. But without me using it, I don't see that I'll making many improvements or changes there. The only brightspot I can see is that the app layout as a whole might work fairly well for a blog editor that I have been planning (PumpkinSeed) to go along with the Pumpkinvine Blog System.

Technorati Tags: pumpkinvine, pumpkinseed, TiddlyWiki, Snowy Woods Journal, python, java script, wxpython

powered by performancing firefox

posted by ScW @ 12/01/2006 01:29:24 AM [permalink] [comments 2]

My First Edgy Install

October 26,2006

So I couldn't help myself, I had to install Ubuntu Edgy Eft on something. I had been meaning to rework my old laptop anyway, so I kicked Breezy off completely, and reformatted. Honestly, I thought Dapper was slick as an install, but this was even easier. The one thing that trips me up still on that old Dell C840 laptop is loading the restricted Nvidia driver. By default, when the system installs... it gets it right, 1600x1200 screen and the whole works but it isn't the Nvidia supplied driver so 3D is dog slow. The trick to making the driver work right (and that's assuming you do the simplest of installs (just search the web for the basic install) ) you still have to change the /etc/modprobe.d/options where they say "nvidia" make it read "nvidia NVreg_Mobile=0". This solution is referenced on the web but it's buried amongst a lot of other things that don't work.

But honestly, it's really just a click and enter a few things kind of installation that is much faster and simpler than a Windows XP install. Dapper and Edgy seem to support so many more devices out of the shute than XP SP2 even does.

The bad news is that Python 2.5 is not the default version. It's available as a secondary version but it's not run by default (i.e. when you type 'python' at a command-prompt). I wonder now how long it'll be before they handle that full upgrade?

Technorati Tags: ubuntu, edgy, linux, dell
posted by ScW @ 10/26/2006 10:30:44 PM [permalink] [comments 0]

Checking the CLR Version in C#.NET

October 03,2006

And now for something completely unrelated to what I have previously been blogging about, I needed to write a quick application that showed the current .NET CLR version that was used to run an application. To get the value for the CLR version you just need to use this static method:
System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()

Now aren't you glad I documented that?

Technorati Tags: c#.net, clr
posted by ScW @ 10/03/2006 07:55:34 PM [permalink] [comments 0]

Other Sites

Past Entries

Links

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.