#!/usr/bin/python

import argparse
import sys


def args():
    parser = argparse.ArgumentParser(description='Run the Furious Examples.')

    parser.add_argument('--gae-sdk-path', metavar='S', dest="gae_lib_path",
                        default="/usr/local/google_appengine",
                        help='path to the GAE SDK')

    parser.add_argument('url', metavar='U', default="", nargs=1,
                        help="the endpoint to run")

    return parser.parse_args()


def setup(options):
    sys.path.insert(0, options.gae_lib_path)

    from dev_appserver import fix_sys_path
    fix_sys_path()


def run(options):
    from google.appengine.tools import appengine_rpc
    from google.appengine.tools import appcfg

    source = 'furious'
    user_agent = appcfg.GetUserAgent()
    server = appengine_rpc.HttpRpcServer(
        'localhost:8080', lambda: ('test@example.com', 'password'), user_agent,
        source, secure=False)

    url = "/"
    if options.url:
        url += options.url[0]

    server._DevAppServerAuthenticate()
    server.Send(url, content_type="text/html; charset=utf-8",
                payload=None)


def main():
    options = args()

    setup(options)

    run(options)


if __name__ == "__main__":
    main()

@@ -49,24 +49,259 @@
 def args():%0A
+    %22%22%22Add and parse the arguments for the script.%0A%0A    url: the url of the example to run%0A    gae-sdk-path: this allows a user to point the script to their GAE SDK%0A                  if it's not in /usr/local/google_appengine.%0A    %22%22%22%0A
     parser =
@@ -738,293 +738,949 @@
     
-sys.path.insert(0, options.gae_lib_path)%0A%0A    from dev_appserver import fix_sys_path%0A    fix_sys_path()%0A%0A%0Adef run(options):%0A    from google.appengine.tools import appengine_rpc%0A    from google.appengine.tools import appcfg%0A%0A    source = 'furious'%0A    user_agent = appcfg.GetUserAgent()
+%22%22%22Grabs the gae_lib_path from the options and inserts it into the first%0A    index of the sys.path. Then calls GAE's fix_sys_path to get all the proper%0A    GAE paths included.%0A%0A    :param options:%0A    %22%22%22%0A    sys.path.insert(0, options.gae_lib_path)%0A%0A    from dev_appserver import fix_sys_path%0A    fix_sys_path()%0A%0A%0Adef run(options):%0A    %22%22%22Run the passed in url of the example using GAE's rpc runner.%0A%0A    Uses appengine_rpc.HttpRpcServer to send a request to the url passed in%0A    via the options.%0A%0A    :param options:%0A    %22%22%22%0A    from google.appengine.tools import appengine_rpc%0A    from google.appengine.tools import appcfg%0A%0A    source = 'furious'%0A%0A    # use the same user agent that GAE uses in appcfg%0A    user_agent = appcfg.GetUserAgent()%0A%0A    # Since we're only using the dev server for now we can hard code these%0A    # values. This will need to change and accept these values as variables%0A    # when this is wired up to hit appspots.
 %0A   
@@ -1829,16 +1829,69 @@
 False)%0A%0A
+    # if no url is passed in just use the top level.%0A
     url 
@@ -1955,42 +1955,135 @@
     
-server._DevAppServerAuthenticate()
+# use the dev server authentication for now.%0A    server._DevAppServerAuthenticate()%0A%0A    # send a simple GET request to the url
 %0A   
@@ -2181,24 +2181,119 @@
 def main():%0A
+    %22%22%22Send a request to the url passed in via the options using GAE's rpc%0A    server.%0A    %22%22%22%0A
     options 

Add docstrings to the example/runner.py module.