Skip to page content Skip to main navigation
English | Site Directory

e.g. "templates" or "datastore"

# Uploading a Python App

The App Engine Python SDK includes a command for interacting with App Engine named `appcfg.py`. You can use this command to upload new versions of the code, configuration and static files for your app to App Engine. You can also use the command to manage datastore indexes and download log data.

- Uploading the App
- Command Line Arguments
- Using an HTTP Proxy

## Uploading the App

To upload application files, run the `appcfg.py` command with the `update` action and the name of your application's root directory. The root directory should contain the app.yaml file for the application.

    appcfg.py update myapp/

`appcfg.py` gets the application ID from the `app.yaml` file, and prompts you for the email address and password of your Google account. After successfully signing in with your account, `appcfg.py` stores a "cookie" so that it does not need to prompt for a password on subsequent attempts.

You can specify the email address on the command line using the `--email` option. You cannot specify the password as a command line option.

    appcfg.py --email=Albert.Johnson@example.com update myapp/

## Command Line Arguments

The `appcfg.py` command takes a set of options, an action, and arguments for the action.

The following actions are available:

`appcfg.py [options] update <app-directory>`

  Uploads files for an application given the application's root directory. The application ID and version are taken from the `app.yaml` file in the app directory.

`appcfg.py [options] rollback <app-directory>`

  Undo a partially completed update for the given application. You can use this if an update was interrupted, and the command is reporting that the application cannot be updated due to a lock.

`appcfg.py [options] update_indexes <app-directory>`

  Updates datastore indexes in App Engine to include newly added indexes. If a new version of your application requires an additional index definition that was added to index.yaml, you can update your index definitions in App Engine prior to uploading the new version of your application. Running this action a few hours prior to uploading your new application version will give the indexes time to build and be serving when the application is deployed.

`appcfg.py [options] vacuum_indexes <app-directory>`

  Delete unused datastore indexes in App Engine. If an index definition is removed from index.yaml, the index is not deleted automatically when the application is uploaded because it may be in use by another version of the application. Run this action when all old indexes are no longer needed.

`appcfg.py [options] request_logs <app-directory> <output-file>`

  Retrieve log data for the application running on App Engine. `output-file` is the name of the file to create, replace or append (if the `--append` flag is set). If `output-file` is a hyphen (`-`), the log data is printed to the console. The following options apply to `request_logs`:

  `--num_days=...`

    The number of days of log data to retrieve, ending on the current date at midnight UTC. A value of 0 retrieves all available logs. If `--append` is given, then the default is 0, otherwise the default is 1.

  `--severity=...`

    The minimum log level for the log messages to retrieve. The value is a number corresponding to the log level: 4 for CRITICAL, 3 for ERROR, 2 for WARNING, 1 for INFO, 0 for DEBUG. All messages at the given log level and above will be retrieved. Default is 1 (INFO).

  `--append`

    Append the fetched data to the output file, starting with the first log line not already present in the file. Running this command once a day with `--append` results in a file containing all log data.

    The default is to overwrite the output file. Does not apply if `output-file` is `-` (printing to the console).

`appcfg.py help <action>`

  Print a help message about the given action, then quit.

The `appcfg.py` command accepts the following options for all actions:

`--quiet`

  Do not print messages when successful.

`--verbose`

  Print messages about what the command is doing.

`--noisy`

  Print many messages about what the command is doing. This is mostly useful when working with the App Engine team to troubleshoot an upload issue.

`--email=...`

  The email address of the Google account of an administrator for the application, for actions that require signing in. If omitted and no cookie is stored from a previous use of the command, the command will prompt for this value.

`--server=...`

  The App Engine server hostname. The default is `appengine.google.com`.

`--host=...`

  The hostname of the local machine for use with remote procedure calls.

`--no_cookies`

  Do not store the administrator sign-in credentials as a cookie; prompt for a password every time.

`--force`

  Force deletion of unused indexes. By default, uploading an app does not delete unused indexes from the server, even if they do not appear in the `index.yaml` file.

`--max_size=...`

  A maximum size of files to upload, as a number of bytes. Files larger than this size will not be uploaded. The default is `1048576`. The server currently enforces a maximum file size of 1,048,576 bytes, so increasing this value will not have any effect.

## Using an HTTP Proxy

If you are running `appcfg.py` behind an HTTP proxy, you must tell `appcfy.py` the name of the proxy. To set an HTTP proxy for `appcfg.py`, set the `http_proxy` environment variable.

Using Windows (in Command Prompt):

    set HTTP_PROXY=http://cache.mycompany.com:3128
    appcfg.py update myapp

Using the command line in Mac OS X (in Terminal) or Linux:

    export http_proxy="http://cache.mycompany.com:3128"
    appcfg.py update myapp