Google App Engine appcfg.py shows the help message for every command - google-app-engine

I have GWT app, which is deployed on GAE (Java). I'm trying to download data from App Engine datastore using appcfg.py . I did all the setup according to http://ikaisays.com/2010/06/10/using-the-bulkloader-with-java-app-engine/ .
GAE Python SDK version is 1.4.3
Python version is 2.5.4
appcfg.py is on my PATH. When I run appcfg.py on the command-line, I get the "help" message. But the problem is that no matter which command I use, it always returns the help message. I have not been able to run any command using appcfg.py.
It doesn't give any specific error message no matter what arguments I give. My app is using Google Accounts authentication, but I don't think it even gets to the point of authentication.
I'm able to use the Java appcfg (for other actions like rollback) without any problem. But the Python version simply refuses to work for all commands.
I've tried different formats like:
appcfg.py create_bulkloader_config --url=http://myappid.appspot.com/remote_api --application=myappid --filename=config.yml
appcfg.py create_bulkloader_config --filename=bulkloader.yaml --url=http://myappid.appspot.com/remote_api
appcfg.py --filename=bulkloader.yaml --url=http://myappid.appspot.com/remote_api create_bulkloader_config
All give me the same help message:
Usage: appcfg.py [options]
Action must be one of:
create_bulkloader_config: Create a bulkloader.yaml from a running application.
cron_info: Display information about cron jobs.
download_app: Download a previously-uploaded app.
download_data: Download entities from datastore.
help: Print help for a specific action.
request_logs: Write request logs in Apache common log format.
rollback: Rollback an in-progress update.
set_default_version: Set the default (serving) version.
update: Create or update an app version.
update_cron: Update application cron definitions.
update_dos: Update application dos definitions.
update_indexes: Update application indexes.
update_queues: Update application task queue definitions.
upload_data: Upload data records to datastore.
vacuum_indexes: Delete unused indexes from application.
Use 'help <action>' for a detailed description.
Options:
-h, --help Show the help message and exit.
-q, --quiet Print errors only.
-v, --verbose Print info level logs.
--noisy Print all logs.
-s SERVER, --server=SERVER
...
...
...
Even when I try "appcfg.py help create_bulkloader_config" for a detailed description, it still shows me the same standard help.
I have also tried on the local development server using the url http://127.0.0.1:8888/remote_api but it still gives the same help message.
I'm totally clueless as to what the problem is. I'm new to GWT and GAE, and any help will be appreciated.
Thanks.

The following fix worked for me. It looks like appcfg.py doesn't like PYTHON27 and ALWAYS returns the help menu. I fixed it by executing it with PYTHON25 and hard coded all my file locations:
C:\Python25-archive\python "C:\Program Files (x86)\Google\google_appengine\appcfg.py" rollback C:\scripts\myapp

The right way is to change the environment variables on Windows 7:
Go to System Properties
Go to Advance System Settings
Click on Environment Variables
Append to Path variable the values C:\Python27\
Click Ok and restart your computer. (Yes, it is needed.)
Another way is to:
Open command Prompt
Locate your python.exe file. For example:
C:\Python27>_
Then, run a python command that looks like this.
python <appcfg_directory> download_app -A <your_app_id> -V <your_app_version> <output-dir>
Where <appcfg_directory> is equal to C:\Program Files\Google\google_appengine\appcfg.py. (Depending on your file location)
Don't forget to put quotes before and after <appcfg_directory>

Related

I want to download code from Google App Engine

I want to update the app in google app store.
But I can't download the code...
Is there any way to update the app without downloading the code?
I tried to download with python, google app engine SDK...
But
appcfg.py download_app -A
This command does not work giving this error
NameError: global name 'execfile' is not defined...
Can you help me with this?
The error you have shown may occur due to incorrect PYTHONPATH environment variable.
If you are using the Windows version of the GAE SDK, then do the following:
1) Go to Edit > Preferences
2) Correct your Python Path.
To know the Python Path in windows do the following in the Python IDLE or Python CMD:
import os
import sys
print os.path.dirname(sys.executable)
For downloading your source code try this:
download_app -A app_name -V version C:\path_to_project
You may or may not need to escape the backslash.
Replace app_name, version and C:\path_to_project with appropriate values
To know the version go to the app engine admin website appengine.appspot.com

How to download GAE logs using maven plugin?

I am using the maven gae plugin for my build and deploy of google appengine app (under windows). All works as expected.
However - I notice its also possible to download the GAE with the same pluggin. It looks to me like something like:
mvn -DoutputFile=./test.log gae:logs
should work - however it just gets stuck at:
0% Beginning to retrieve log records...
and goes no further - what am I doing wrong?
Using
mvn -e
or
mvn -X
don't seem to provide any helpful output
I tried an absolute path as well on OSX and it refuses to honor the -DoutputFile argument and puts the logs in target/gae.log no matter where I try and tell it to put it or name it instead.
So go look in your project_dir/target/gae.log file

Request_logs on Google App Engine - append erases for new version?

I set up a cron job to download the logs using the following code:
echo [password] | appcfg.py request_logs --num_days=1 --severity=0 --append --passin --email=[user] --quiet /tmp/code/ ~/site_logs/`date +%m-%d-%y`.txt
I run it every 5 minutes, which is great for having the latest logs available to grep through. However, if I bump the version number, the log doesn't seem to honor append. It just writes over the file.
Am I missing something? Is there a better way to get this to continuously dump the logs to disk?
If you're still having this problem, you could expose a minimal API to expose the current version id and query that before fetching. It's hacky but it works.
The currently serving version ID can be retrieved using os.environ['CURRENT_VERSION_ID']. See: https://developers.google.com/appengine/docs/python/runtime

Google App Engine: appcfg.py rollback

I'm using Windows 7 and for the life of me I cannot figure out how to call the rollback function on appcfg.py. All I want to know is what to type into the command prompt so I can rollback my app.
Try this: appcfg.py rollback <directory>
If your application myapp resides in C:\Users\Nilesh\Documents\ then directory path should be C:\Users\Nilesh\Documents\myapp
If you installed Google App Engine Launcher in your system, then installation path should be something like this C:\Program Files\Google\google_appengine
Now open the command prompt and type the following:
C:\Program Files\Google\google_appengine>appcfg.py rollback C:\Users\Nilesh\Documents\myapp
This will solve your issue. :)
The rollback command can rollback a transaction on the server, but you are unlikely to need to use that unless an update of your app failed for some reason. You should be getting some feedback from appcfg.py that such an action is required. Is that what you want to do? If so, just open a command prompt and type appcfg.py rollback.
Otherwise, please let us know what you are trying to accomplish by performing a 'rollback'.
E:\eclipse-jee-indigo-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.6.1.v201201120043r37\appengine-java-sdk-1.6.1\bin>appcfg.cmd rollback E:\AdminApp\Admin\war
For Rollback Java Application
try this :
this was how I did it (all from the command line) which is a slightly simpler
method, which achieved the same effect.....
C:\Documents and Settings\Amit\My Documents\newproject>"C:\Program
Files\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.2.5.v200909021031\appengine-java-sdk-1.2.5\bin\appcfg" rollback war
Reading application configuration data...
2009-09-17 20:47:35.859::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
Beginning server interaction for idebanet...
0% Rolling back the update.
Success.
Cleaning up temporary files...
C:\Documents and Settings\Amit\My Documents\newproject>
If you use maven for deploying your app (with goal appengine:update), then you can also run maven with goal appengine:rollback. It solved the issue for me.
I couldn't get mine to work, until I did this:
C:\Program Files (x86)\Google\google_appengine>python appcfg.py rollback "C:\Pro
gram Files (x86)\Google\google_appengine\mirror-quickstart-python"
I had to add in the double quotes and "python" before the appcfg.py
Here is how I did this on my Linux machine (after many trials and errors):
cd ~/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/com.google.appengine.eclipse.sdkbundle_1.5.1.r35v201106211634/appengine-java-sdk-1.5.1/bin
chmod +x appcfg.sh
./appcfg.sh -s appengine.google.com -e [my-email]#gmail.com rollback /home/erelsgl/workspace/ImitatorGWT/war
Hope this helps.
10, I had this problem little while ago and I have resolved it.
First, I moved to bin directory using:
cd ~/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/com.google.appengine.eclipse.sdkbundle_1.5.1.r35v201106211634/appengine-java-sdk-1.5.1/bin
Then, I ran the rollback command:
./appcfg.sh rollback /home/workspace/vchat/war
I hope this will help.
Here I have fix it on my ubuntu machine:
cd /home/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.6.5/appengine-java-sdk-1.6.5/bin/
sh ./appcfg.sh -A appId -s appengine.google.com -e youdID#google.com rollback /home/workspace/projectName/war
Hope this helps
For all those who deploy using Google App Engine Launcher, you can fix the issue by opening command prompt and python appcfg.py rollback <directory of your application>
In my case, I have not set up Python env variable so:
C:\Python25\python C:\Program Files\Google\Google App Engine\appcfg.py rollback C:\eclipse\applicatoin
In Linux uploading an App through appcfg creates a staging directory in /tmp
0% Created staging directory at: '/tmp/appcfg8593320566371318406.tmp'
To rollback you may also this directory in rollback command
appcfg.sh -A yourAppId -s appengine.google.com rollback /tmp/appcfg8593320566371318406.tmp
After experiencing quite a it of frustration trying to 'appcfg rollback' on my Mac, I read Jaky's answer and resolved the problem in a couple of minutes by changing the version number.
If you're using eclipse, just open the appengine-web.xml under war>WEB-INF in the project & change the version number there.
Very late to the game, but I'd like to add what worked for me in Windows XP. In a command prompt:
C:\Python27>python C:\Progra~1\Google\google_appengine\appcfg.py rollback C:\Docume~1\myname\MyDocu~1\Projects\myproject\
Python 2.7 and the short names in the Windows path were key.
I am using 64 bit Windows7 with GAE-Java Typing all this detail at the command prompt can be frustrating. My solution: create a batch file.
I created a batch file named 'rollback.bat' & saved it in my WORKSPACE directory. The contents look like this:
cd C:\Users\Organize4Joy\My Code\EclipseWORKSPACE\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.8.3\appengine-java-sdk-1.8.3\bin\appcfg.cmd rollback C:\Users\Organize4Joy\EclipseWORKSPACE\iTreewareMAIN\war
run the batch file by simply typing "rollback"
this local utility changes directory, runs the appcfg rollback EXE & points it to my war directory.
Even better would be to establish a common utility(bin) directory and add it to my path variable. That way I can run this utility from anywhere.
Traverse to the path where the appcfg.py is placed
Run the Command python appcfg.py rollback (The Directory of your project folder)
Open dos
place yourself in the folder containing appcfg.cmd (bin of the GAE SDK)
If your application myapp resides in C:\Users\Nilesh\Documents\ then directory path should be C:\Users\Nilesh\Documents\myapp\war.
Now open the command prompt and type the following:
appcfg.cmd rollback C:\Users\Nilesh\Documents\myapp\war
Note don't forget to add 'war' at then end of your app folder
then enter your email and password
This has been answered many times, but I had issues getting it to work for me too. If you are running Java and are also having problems or if you have Google's 2 factor authentication setup and that is giving you problems, here are the steps I used to make it succeed:
1) Make sure you have the Google App Engine in your Path in Environment variables.
IE: C:\Users\yourUserName\Desktop\Eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.9.18\appengine-java-sdk-1.9.18\bin
2) Open up a command window AS AN ADMINISTRATOR! Do not just type cmd and enter, you need to type cmd, right-click on it, and open as admin
3) First, CD to the folder that has the WAR file in it. In my case, that was:
cd "C:\Users\yourUserName\Documents\MyWorkspace\Project1"
This is the same folder that has the src, .settings, and war folders in it.
4) In the cmd window, type: "appcfg rollback war" and press enter.
5) It will ask for your google credentials. If you do not have 2 factor authentication setup, simply type them in and press enter and you will be set.
6) If you DO have 2 factor authentication setup, go to your google accounts page (Just google for 'google account') and it will be the first or second one.
Next, under the "Signing In" category, go to App passwords.
Next, go to the bottom and under the select app dropdown menu, choose other and type in anything (IE: GAE rollback)
It will give you a password (16 digit random numbers).
Finally, type in your email address in the command window and then type/ paste in this new temporary 16 digit password into the password section.
7) Profit!
-Sil
In my case, I had to use the --no_cookies, without it, I had no premissions to do the operation.
C:\Users\user_name.gradle\appengine-sdk\appengine-java-sdk-1.9.30\bin\appcfg --no_cookies --application=app_name --version=1 rollback C:\projects\android\app\backend\build\exploded-app
I don't know much about these coding things everyone is talking about here..but I found a simple way to update the application..
Select your application and click on "EDIT".
A wordpad file should open up with application details.
Below the application there is version:1
Simply change the version to version:2 instead of 1 and click "Save".
So, instead of updating the same version..you are deploying a new version..
Click on "DEPLOY".
Check your application now!

How do I download the source code of a google app engine project?

This seems like it should be very easy but I don't see a link to it anywhere.
How do I download the source code of a google app engine project?
Windows
appengine-java-sdk\bin\appcfg.cmd -A <your_app_id> -V <your_app_version> download_app <output-dir>
Linux
./appengine-java-sdk/bin/appcfg.sh -A <your_app_id> -V <your_app_version> download_app <output-dir>
For completeness, using the Python implementation:
appcfg.py download_app -A $appID -V $appVersionNumber $downloadDirectory --oauth2
--oauth2 is of course optional, you can omit it and provide your email + app-specific password (or your password, and then go implement two-factor authentication right after), but it's easier, and frankly there's no reason not to.
Documentation.
App Engine actually recently added the ability for the developer who uploaded a given app version to download its source code.
As of October 2019 you can simply go to --> App Engine --> Services and in the tool dropdown select 'source' and the source code is there
Posting this since none of the listed methods above didn't take me to the code (by June 2021)
You could try accessing it through;
Google Cloud Platform > Debugger > choosing the version of the
Application from combo at top.
This will list the files of that version on the left pane. There is no way to download it automatically but you can copy-paste the code.
Hope you will find this helpful.
IMHO, the best option today (Aug 2018) is:
Under the main menu, under Products, go to Tools -> Cloud Build -> Build history.
There, click the ID of the build you want (for me - the last one).
Then, in the opened window (Build details), click the "source" link, the download of your compressed code begins.
As simple as that.
HTH.
Working with App engine standard using Go, the debugger isn't available yet.
How I managed to download the source code for an existing service was to use the gcloud tool.
First: Get the version id of your service using the app engine console or running: gcloud app versions list
Second: use the version and service name and run: gcloud app versions describe <versionID> --service=<service name>
the describe parameter will give you the storage locations for your source files that looks like this:
cmd/main.go:
sha1Sum: e3fe5848c2640eca7ac3591490e1debc2d3a9b09
sourceUrl: https://storage.googleapis.com/<project>/<file id>
Third: you can then use the storage console, using the file id, to download the files you are interested in.
this process based on java sdk
Its works for me...
Download Google cloud SDK
gcloud init
enter image description here
Follow through process of logging in using your credentials
Enter following command from SDK
C:\Program Files (x86)\Google\appengine-java-sdk-1.9.49\bin
enter image description here
Enter Following command to download source code
appcfg.sh -A [YOUR_APP_ID] -V [YOUR_APP_VERSION] download_app [OUTPUT_DIR]
Eg: appcfg.sh -A my-project-name-1234 -V 2 download_app C:\Users\india\Desktop\my project
Note: this progress based on java-appengine sdk so we use appcfg.sh instead of appcfg.py
check if your app is uploaded with same email id that is in your app engine. if you are not sure then in app engine > control > Clear deployment credentials and then click on any project, deploy to sign in again then use this
appcfg.py download_app -A {app id from google app engine} -V {1} "{c:\path}" --oauth2_credential_file=C:\Users\{your account name}/.appcfg_oauth2_tokens
change all {} to your needs
Things have changed since this question was asked so I'm adding an updated answer. Note that this only applies to GAE Standard Environment
Google has deprecated appcfg.py and so the previous responses appcfg.py download_app no longer works.
gcloud which is the SDK in use (it replaced appcfg) does not have the functionality to download your source code.
When you deploy your app via gcloud app deploy, it copies your source code to a bucket. The default bucket is staging.<project_name>.appspot.com. Your files will stay in this bucket for a maximum of 15 days before they are deleted. You can modify the rule so that the files are retained for longer or less time.
The file names in the bucket are encoded so you can't figure out what each file is unless you open it (i.e. download it). Google has a mapping of the encoded names to the original file names. To get this mapping, you run the gcloud app versions describe command and it will list the file names and their encoded names. To download the files, you have to manually click each url one by one. So essentially, you have to download each file manually and then use the mapping to rename them (or open the file, check the content and then rename them). Also note that downloading the files manually will not maintain the folder structure in which they were uploaded.
If you do not wish to go through all of the above hassles (imagine having to manually open each url for each file if you have a small to mid-sized project which has hundreds of files), our App - https://nocommandline.com - now supports downloading source code from the default bucket - staging.<project_name>.appspot.com (so far as your files are still there which means any deployment i.e update not older than 15 days from your current date unless you previously increased the deletion age on your staging bucket's lifecycle page).
In simple terms, you enter your project name, the version number and our App will take care of retrieving the original file name to encoded name mapping, automatically downloading the files and renaming them to the original names, while maintaining the folder structure. For more information, refer to https://nocommandline.com/help/#faq_download_source_code_from_gae.
Log in to the console.developers.google.com
Select the project you want to download the code from (Google App Engine Standard Envoronment).
Go to the App Engine Dashboard. Under Summary is Debug and Source. Click on Source.
Select each file one at a time and copy it (highlight the code, copy and paste into your local editor.)
Select the next file....
You need to use svn to checkout the files.
If you are on Windows, you can use tortoise svn for your GUI end.
Here are tutorials on how to do it, here is the related question.

Resources