Tuesday, December 08, 2009

Continuous Quality of .py files on app engine experiments

I've been working on a few small experiments with appengine capabilities (sending e-mail, receiving e-mail, sending and receiving instant messages over xmpp) . It has given me the chance to try Ale on some projects smaller than Flexvite, and I've really enjoyed it.

Typically I get the skeleton of the experiment up in about 60 seconds by using the helloworld quickstart, then adding pyflakes and watcher into the mix with 'ale install pyflakes' and 'ale install watcher'. Once I have spun up 'ale watcher', I've got something that is continuously checking my .py files for extraneous imports, undeclared vars, etc. It's really very nice to be told that you can loose two or three imports and simplify your codebase -- even when your codebase is small! Of course 'ale watcher' can also be used to trigger the running of unit testing or other checks, but for the experimental nature of these projects, that didn't seem necessary.

So for these experiments, my ale setup looks like:

$ ale

Syntax: ale <command>

Core commands:
list list commands currently recipes_installed
create create -- create the skeleton for a new command
install install
remove remove Uninstalls a command
search search commands available for install

Additional Commands:
gae google app engine .ale
pyflakes run pyflakes (lint tool) against the project or pyflakes [dir]
watcher monitors files matching a filespec for change and triggers command(s)

$


which is something I'm liking a lot.... you can see the commands I'm using with the project without a lot of extraneous stuff.

Starting it up is as simple as 'ale gae start' (which launches the server, and a browser to the app), and deploying it to the google cloud infrastructure (appengine) is as simple as 'ale gae deploy'.

It also turns out to be pretty simple to add these to the ale 'createapp' command (using the tarballs generated by github), so I went ahead and did that so that it's easy to pull one down quickly when you need it:


$ale createapp

createapp [templatename] -- create an app from a template
available app templates:
helloworld -- simple helloworld app
helloworldwebapp -- simple helloworld app using webapp fmk
xmppsendandreply -- simple xmpp (instant message) send and reply
emailreceive -- simple e-mail receive example
emailsendui -- simple e-mail send example

$

Friday, December 04, 2009

App engine [local] hello world in 60 seconds

I'm toying around with a little experiment at http://github.com/mpstx/Ale It helps you get a tool stack configured quickly to do appengine development without affecting your system's default python environment or installed apps -- something I spent more than a little time rolling by hand during the development of Flexvite. Here's a little preview:

To create an _Isolated_ (no global installs/sudos!), local App engine hello world on OS X in 60 seconds, do this:

  1. Environment setup :
    mkdir aehello; cd aehello

  2. Install Ale :
    git init; git submodule add git://github.com/mpstx/Ale.git .ale

  3. Init Ale :
    .ale/init.sh

  4. Install appengine :
     ale install gae

  5. Install createapp :
    ale install createapp

  6. Create a basic app :
    ale createapp helloworldwebapp

  7. Start local server and browser :
    ale gae start



You can now edit helloworld.py and refresh the browser...change should be reflected instantly.

To delete everything just rm -rf the aehello directory and you'll be totally clean again.

To Deploy it to the cloud...

  1. Go create a google app engine account.

  2. create an appid

  3. modify your app.yaml to reflect your new id

  4. To deploy to yourappid.appspot.com :
    ale gae deploy