Archive for the 'Python' Category

Geographic Queries on Google App Engine

Posted in Locality and Space, Python on May 28th, 2008 at 12:05:13

I made a post over on the MetaCarta Labs blog about doing geographic queries on App Engine:

???????? ????? ????????In this way, I was able to put together a geographic bounding box query, on top of Google App Engine, using a Geohash-like algorithm as a storage format, and use that query to power a FeatureServer Demo App Engine application, doing geographic queries of non-point features on top of App Engine/BigTable. Simply create a Geoindex object of the bounding box of your feature, and then use lower-left/upper-right points as bounds for your Geohash when querying.

Geographic Queries on Google App Engine

Probably of interest to some of the people who read this.

First Attempt at IronPython

Posted in IronPython, Locality and Space, Python, TileCache, default on June 20th, 2007 at 06:53:26

My first attempt to do something useful with IronPython:

>>> import urllib
>>> urllib.urlopen("")
Traceback (most recent call last):
  File httplib, line unknown, in getreply
  File httplib, line unknown, in getresponse
  File httplib, line unknown, in __init__
  File System, line unknown, in set_ReceiveBufferSize
  File System, line unknown, in SetSocketOption
WindowsError: Invalid arguments

Note that I’m working on OS X, and my exception is a WindowsError. Fancy.

(I was inspired by Bill Thorp’s efforts to get TileCache working on IronPython: Round 1, Round 2. However, I’m not all that inspired now.)

Still, it is kind of cool that IronPython just ran — I didn’t expect that to work. Maybe there’s something to this mono business after all.

TileCache Under Windows… It Just Works ™

Posted in Apache, Python, TileCache on February 7th, 2007 at 10:53:06

It’s cool when software works.

So, I needed to test the latest TileCache in Windows. I’ve got a relatively clean Windows laptop I keep around for this. None of the niceties that I would typically want on a machine I used full time — no Firefox, no cygwin, no vim, etc. Just a straight up Windows install, with things like Google Earth installed.

So, starting from that, I started by downloading Apache from the Apache Download Page. I downloaded “Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.msi“, and ran the installer directly. This got http://localhost/ serving a page that says “It works!”.

Next, I downloaded the Python 2.5 Windows installer , and again selected all the defaults.

Next, I downloaded TileCache 1.4, as a .zip file, since I know how well Windows supports .tar.gz files. I extracted the zip file into C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin.

Lastly, I edited C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin\tilecache-1.4\tilecache.cgi so that the first line of the file read “#!C:/Python25/python.exe -u”, and visited http://localhost/cgi-bin/tilecache-1.4/tilecache.cgi/1.0.0/basic/0/0/0.png …

And it worked! I got an image. I never expected setting up Apache, Python, and TileCache to just… well… work.

optparse module

Posted in Programming Languages, Python on January 14th, 2007 at 12:49:19

Wow, I’d never used the optparse module before. That’s pretty damn cool. (And to think I came close to writing my own option parser for a bit before I looked up the documentation.) The automatic addition of –help output is super-cool too. I definitely need to start using this in more of my code.

Hooray for Python!

Regular Expression HOWTO

Posted in Python on June 19th, 2006 at 02:01:14

Whenever I’m about to do something with the Python Regular Expression module, I immediately google “amk python re”, which leads me to A.M. Kuchling’s RE HOWTO. I can’t think of anything that I would find useful with regular expressions that is not covered in this document, and I highly encourage you to use it as a reference when you think you might find it handy.

Learning Letters

Posted in Ning, Python on February 8th, 2006 at 11:48:39

Julie’s at home these days - since we found out she’s deaf in one ear, we pulled her out of school to do more one-on-one learning at home.

She’s good at associating words with the visual representation of the letter - she’ll see “S”, and say “That’s what Sienna’s name starts with!” - but bad at names of letters. So, I hacked up a quick wxPython script from the wxPython samples that will just show an uppercase and lowercase letter, which she can click through. It’s basically a quick-and-dirty flashcard program: source available, of course.

Because I wanted to track her progress, I hacked up a little Ning App to track her learning. As of today, she only recognizes J (for Julie) and X on the first try. So, we’ll track it and see how she does. LearningLetters. 20 minute app, probably less. It’s crude, but it works.

It’s easy to make this work for just about anything you want to track. Just modify the ‘choices’ array.

XQuery: Remote XN_Querys

Posted in Ning, Python on February 2nd, 2006 at 23:41:12

I said a while ago that the coolest part of Ning was the content store. I’m now working on a proof of concept to prove it.

So, there’s a bunch of Roshambo (Rock Scissors Paper) apps. Or at least a couple. Or at least two: Roshambo and Fifteen, my personal 15-option version.

So, I know that I’ve played a handful of games, and don’t want to scroll back through them. The app itself doesn’t offer an API itself, so there’s no easy way to get the data out, and I hate screenscraping.

So, I built a query app. XQuery. The homepage kind of documents what it can do so far, but it’s nowhere near done. It was just a one hour hack. Then I built the Roshambo Results Viewer. I also then extracted the logic into a simple Roshambo Python Script — usage ‘python crschmidt’.

Expect more to come of this.

GPS Display

Posted in Bluetooth, GPS Devices, Mobile Platform, Python, Symbian Python on January 14th, 2006 at 14:32:32

Today, there are a large number of cheap bluetooth GPS devices on the market. These devices allow you to connect to the device wirelessly, which is great for when you’re driving and don’t want cables draped all over the car.

However, what happens when you can’t drag your computer out to act as a display of your position? No bluetooth GPS on the market today for under $500 has a display of any kind. When you consider that these things can be had for $70, that makes purchasing one go from likely, to ridiculous. What’s the point of a handheld, easy to use GPS if you can’t use it to see where you are?

GPSDisplay ScreenshotIf you’ve been asking this question, I’ve got software which has an answer for you. GPSDisplay will allow you to connect to NMEA compatible Bluetooth GPS devices and display your position fix. It is written entirely in Python, using NMEA code from Forum Nokia. It requires only that you first install Python for Series 60 on your device, and should work on all first and second generation Series 60 phones. Simply download the .sis file, send it to your phone, and you’ll be all set to go — you can use your phone as a display for that new cheap Bluetooth GPS you bought, and stop dragging your laptop out into the woods to go Geocaching.


Posted in Geolocation, Mobile Platform, Ning, Python, Symbian Python on October 14th, 2005 at 10:23:43

In my spare time (hah!) I’ve been hacking on an app on Ning, called PeopleFinder. The goal is to be a geolocation app, supporting a variety of things social. One of my many goals for a long time has been to create and use some kind of tool which allows me to generate MeNow data with no effort.

I’ve finally got it.

With the help of Geocoder, I can now type in an address, and have it automatically update my location on the website, including showing my position on a GMaps interface. The PeopleFinder API is still a bit weak, but using it, I can write a Client for Series 60 Python, which allows you to update via a GPS lat and long, or via an address.

I’ve created a token system for authentication via the API — when logged in, you simply hit the token link, grab the token, and put it into the client (in the “token” variable).

Eventually, once I write the functionality, it is my hope that I will be able to provide more features via this API — the ability to look for people nearby you, get their information, send them messages, and so on. However, right now this is just a 2-3 hour hack, and I’ve got piles of work to do - but this is so cool I had to share it.

As far as I know, this is the first example of a Ning App exporting a semi-usable API to remote clients. In part, this may be due to previous limitations on Ning’s end which have recently been resolved: looking at the phone client code, you’ll see the ?xn_auth=no parameter, which allows you to skip cookie authentication. It’s a pretty nice solution to the problem in my opinion — it solves what I need while not interfering with the rest of Ning.

So grab your phone, grab a client, and update your address on the go — then, the next time I see you in the neighborhood, I’ll drop by and give you a wave.

Python SIG

Posted in Python on July 30th, 2005 at 08:37:08

On Thursday night, I attended the first meeting of what looks to become a great group of people, at the first PySig meeting, in Manchester, NH. The meeting release has some more information on it, and the mailing list is a great place for discussion of it for people who may be interested.

It was interesting to speak to a mixture of people ranking from 20 years in the computer industry to people like me with one or two, and note that they were all interested in learning Python - and that I definitely had a thing or two up on most of them in this day and age. For example, in a room of 20 participants, several of whom have been working with Python for years, I was the only person who had actually had work posted to Daily Python URL.

During the meeting, I wrote some code (a clunky registration page) which we then did some initial code review on. I demonstrated a trick I learned from sbp, including a “View Source” part of my application so people could see exactly what it was doing.

I’m falling back in love with Python quite quickly. This is nice for a number of reasons, not the least of which is the start of a bit more free time as of this week. I’ll explain that in a later post.

Mostly, I’d like to put out the word to anyone that attended that I had a great time, and I’d love to see more people in the area attend. So far as I can find, there is no group of people in the Northeast that has as much coverage as the website: there’s been a couple postings around Boston, but nothing big enough that they have a website. I’d be glad to find out I’m wrong, however, so feel free to tell me so. :)