Wednesday, April 28, 2010

Google App Engine - printing debug messages

The logging.debug statements are not printed by default in the local development server of Google App Engine projects. In order to display these messages, you need to add the "--debug flag" to the launch settings. Here are the steps to do so:

1. Open GoogleAppEngineLauncher
2. Right-click on your app engine project
3. Select Info...
4. In the Launch Settings section, enter "--debug" in the Extra Flags box.
5. Click Update.

Restart the server. The Logs should now display DEBUG statements in addition to warnings and info.

Thursday, April 8, 2010

Unzipping jar files

Wow, opening jar files is much easier than I realized! I had been expanding them from the command line for a couple years now. Today, I just found this page: All I have to do on my Mac is change the extension to .zip and double click. Wow.

Sunday, April 4, 2010

Installing rdflib - Mac OS X 10.5.8

Installing rdflib seems easy enough, but I ran into a couple of weird issues that were not documented anywhere online. I wanted to share my experience in case anyone else ran into these same problems!

First, I tried the easy_install command recommended by the site. This was the output I received:

Searching for rdflib==2.4.2
Best match: rdflib 2.4.2
Processing rdflib-2.4.2.tar.gz
Running rdflib-2.4.2/ -q bdist_egg --dist-dir /var/folders/Lr/Lrriod8lEEm63-sPBZf6XE+++TI/-Tmp-/easy_install-xa0EVw/rdflib-2.4.2/egg-dist-tmp-qvivjK
warning: no files found matching ''
zip_safe flag not set; analyzing archive contents...
No eggs found in /var/folders/Lr/Lrriod8lEEm63-sPBZf6XE+++TI/-Tmp-/easy_install-xa0EVw/rdflib-2.4.2/egg-dist-tmp-qvivjK (setup script problem?)

Uh, no egg found? I suppose that's somewhat appropriate, it is Easter today (darn Easter bunny!). I didn't think I could easily solve this problem, since there might be a problem with the setup script.

So, I tried downloading the tar file. Upon unpacking the file, there was a file. Great! I just need to run python install, right? Wrong.. here's the output:

Traceback (most recent call last):
File "", line 1, in
from setuptools import setup, find_packages
ImportError: No module named setuptools

OK, I checked the directory again, and noticed that there was an file. Maybe this would do the trick? I ran python, and there were no errors! Here was the output:

Processing setuptools-0.6c9-py2.5.egg
Copying setuptools-0.6c9-py2.5.egg to /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages
Adding setuptools 0.6c9 to easy-install.pth file
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.5/bin
Installing easy_install-2.5 script to /Library/Frameworks/Python.framework/Versions/2.5/bin

Installed /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg
Processing dependencies for setuptools==0.6c9
Finished processing dependencies for setuptools==0.6c9

Looks like this solves the earlier error I received when running python install: the setuptools package was created! Great! I ran python install again, and rdflib was successfully installed...

with one caveat: the build files are located in build > lib.macosx-10.3-fat-2.5 (or some similar directory) > rdflib. Make sure to put this path in your PYTHONPATH. So far, I found one file in here that is necessary for running SPARQL queries, It's not in the rdflib directory at the root of the rdflib-2.x.x directory!

Good luck!

Saturday, April 3, 2010

Bulk Upload Data to App Engine Dev DB

NOTE: these instructions are for the previous version of App Engine!

How to upload bulk data to App Engine Dev:

1. Create a loader file:
import datetime
import main
from google.appengine.ext import db
from import bulkloader

class ClothesLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'Clothes',
[('title', lambda x: x.decode('utf-8')),
('image', lambda x: x.decode('utf-8')),
('type', lambda x: x.decode('utf-8')),
('tag', lambda x: x.decode('utf-8'))

loaders = [ClothesLoader]

2. Create a CSV file with your data. Example:
 Jeans, http://localhost:8080/images/jeans1.jpg, bottom, spring

3. In your app.yaml file, MAKE SURE you have the following lines:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/

4. Also make sure that your PYTHONPATH env var has the directory in which you saved your models. On a Mac:
 export PYTHONPATH=$PYTHONPATH:<directory>

5. Finally, run the following command: upload_data --config_file=<loader python file> --filename=<csv data file> --kind=<model name> --url=http://localhost:8083/remote_api <app directory>