Downloading your code from Google App Engine

posted mid-afternoon by Constantinos. Filed under General

This post was originally published in 2008
The tips and techniques explained may be outdated.

I've started using Google's App Engine since it launched, mostly playing around with Python (always wanted to learn), and setting up a small app to deal with my Desktop Photo Feed script. One irritation I had was that I wanted to share my code with a friend, but the app engine doesn't provide any way of downloading the source code.

One way around this that I found, was a blog post by David Burger on Download Your Code from Google App Engine, where he created a Makefile to do the dirtywork. Because I don't like Makefiles (and have it from good authority that Googlers hate Makefiles too, but that's besides the point - just to reinforce my position), I modified his method to make it slightly more versatile so that it can work well with OS X (tar includes ._* resource fork files which are annoying), and also turn it into a shell script.

There are two steps to the process. First, save this code as a file called something like update.sh in the base folder where your app code is located, and make it executable:

ARCHIVE_DIR=archive
ARCHIVE_NAME=`basename $PWD`.tgz
 
rm -rf ${ARCHIVE_DIR}
find . -name "*~" -delete
find . -name "*pyc" -delete
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
export COPYFILE_DISABLE=true
tar -czf ${ARCHIVE_NAME} --exclude .DS_Store --exclude ${ARCHIVE_NAME} -C ../ `basename $PWD`
mkdir -p ${ARCHIVE_DIR}
mv ${ARCHIVE_NAME} ${ARCHIVE_DIR}
appcfg.py update ./

Download this script

Then, you would probably want to password protect the resource that points to this archive file, so add this to your app.yaml file:

- url: /archive
  static_dir: archive
  login: admin

Now, whenever you wish to update your app, just execute ./update.sh instead of ./appcfg.py update ./, and the archive of your source will be created and uploaded with your changes. To download, assuming the folder your application is in has the same name as your application, just visit http://yourapp.appspot.com/archive/yourapp.tgz where yourapp is your app's name, and yourapp.tgz is your app folder's name if it's different from your app's name, and you will be prompted to download the archive assuming you're logged in as administrator. That's it!

One Response to “Downloading your code from Google App Engine”

  1. 1. Pingback by Downloading your code from google app engine (in windows) - Johnny Ye’s Blog
    on 11 Aug 2009 @ 2:42 am

    […] does have anything that allows developer to download the code. Thanks to Voodoo programming blog ( http://www.cneophytou.com/2008/04/17/downloading-your-code-from-google-app-engine/ ) It shows a way to do it in mac, I take a similar approach in […]