appcfg.py 无法在命令行中工作
appcfg.py not working in command line
我只是有点难以理解为什么要执行此命令:
>appcfg.py -A adept-box-109804 update app.yaml
Try Google App Engine Now 页面给出的内容不起作用。我已经为 Python 下载了 App Engine SDK,并将 Path 设置为指向 appcfg.py 的位置,但是我的项目根目录中的 运行 appcfg.py 不起作用在命令行中。我要么必须导航到包含 appcfg.py 的文件夹并执行
>python appcfg.py help
或者
>python "C:\Program Files (x86)\Google\google_appengine\appcfg.py" help
让命令可以在任何地方工作。我使用后一种方法来部署我的测试应用程序,但只是想知道是否有人可以解释为什么简单 Google 教程给出的命令没有执行任何操作。我还检查以确保使用 Python 2.7 解释器自动打开 .py 文件,以便只需在命令行中键入
即可执行文件 hello.py
>hello.py
它会输出它的打印语句。另一方面,无论参数如何,以类似的方式使用 appcfg.py 都会得到相同的输出(请注意我截断了输出,但请放心,无论参数如何,它们都是相同的:
C:\>appcfg.py help backends
Usage: appcfg.py [options] <action>
Action must be one of:
backends: Perform a backend action.
backends configure: Reconfigure a backend without stopping it.
backends delete: Delete a backend.
backends list: List all backends configured for the app.
backends rollback: Roll back an update of a backend.
backends start: Start a backend.
backends stop: Stop a backend.
backends update: Update one or more backends.
create_bulkloader_config: Create a bulkloader.yaml from a running application.
cron_info: Display information about cron jobs.
delete_version: Delete the specified version for an app.
download_app: Download a previously-uploaded app.
download_data: Download entities from datastore.
help: Print help for a specific action.
list_versions: List all uploaded versions for an app.
request_logs: Write request logs in Apache common log format.
resource_limits_info: Get the resource limits.
rollback: Rollback an in-progress update.
set_default_version: Set the default (serving) version.
start_module_version: Start a module version.
stop_module_version: Stop a module version.
update: Create or update an app version.
update_cron: Update application cron definitions.
update_dispatch: Update application dispatch 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.
C:\>appcfg.py help update
Usage: appcfg.py [options] <action>
Action must be one of:
backends: Perform a backend action.
backends configure: Reconfigure a backend without stopping it.
backends delete: Delete a backend.
backends list: List all backends configured for the app.
backends rollback: Roll back an update of a backend.
backends start: Start a backend.
backends stop: Stop a backend.
backends update: Update one or more backends.
create_bulkloader_config: Create a bulkloader.yaml from a running application.
cron_info: Display information about cron jobs.
delete_version: Delete the specified version for an app.
download_app: Download a previously-uploaded app.
download_data: Download entities from datastore.
help: Print help for a specific action.
list_versions: List all uploaded versions for an app.
request_logs: Write request logs in Apache common log format.
resource_limits_info: Get the resource limits.
rollback: Rollback an in-progress update.
set_default_version: Set the default (serving) version.
start_module_version: Start a module version.
stop_module_version: Stop a module version.
update: Create or update an app version.
update_cron: Update application cron definitions.
update_dispatch: Update application dispatch 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.
您的困惑可能源于混淆了 2 种可能的调用样式:
python appcfg.py ...
appcfg.py ...
第一个无法利用 appcfg.py
的位置在路径中这一事实,它只是 python
可执行文件的参数,无法定位appcfg.py
文件,除非:
- 它在当前目录中找到它
appcfg.py
文件使用完整路径或相对于调用 python
的当前工作目录的路径指定
这就是您的第 2 条和第 3 条命令无法按预期工作的原因。如果 appcfg.py
的位置在路径中,则使用第二种调用方式应该有效——就像你最后一次调用命令一样。
要记住的要点:路径配置仅适用于命令可执行文件,而不适用于其参数(顺便说一句,每个可执行文件都可以按照自己的意愿进行处理,some 可执行文件可能将参数与路径配置相结合以获得文件的位置。
同样,appcfg.py
本身(一旦使用 2 种调用方式中的任何一种成功调用)需要能够找到指定为参数的 app.yaml
文件。它不能这样做,除非:
- 它在当前目录中找到它
- 使用完整路径或相对于调用
appcfg.py
的当前工作目录的路径指定 app.yaml
文件(或其目录)
我怀疑 appcfg.py
无法找到您的 app.yaml
文件可能是您提到的第一个命令不起作用的原因。如果不是,您应该提供有关失败的详细信息。
关于为什么无论参数如何,最后一个命令的输出都是相同的,我不确定,这可能是 SDK windows 版本中的错误。在 linux 中输出不同:
> appcfg.py help backends
Usage: appcfg.py [options] backends <directory> <action>
Perform a backend action.
The 'backends' command will perform a backends action.
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
The App Engine server.
-e EMAIL, --email=EMAIL
The username to use. Will prompt if omitted.
-H HOST, --host=HOST Overrides the Host header sent with all RPCs.
--no_cookies Do not save authentication cookies to local disk.
--skip_sdk_update_check
Do not check for SDK updates.
-A APP_ID, --application=APP_ID
Set the application, overriding the application value
from app.yaml file.
-M MODULE, --module=MODULE
Set the module, overriding the module value from
app.yaml.
-V VERSION, --version=VERSION
Set the (major) version, overriding the version value
from app.yaml file.
-r RUNTIME, --runtime=RUNTIME
Override runtime from app.yaml file.
-E NAME:VALUE, --env_variable=NAME:VALUE
Set an environment variable, potentially overriding an
env_variable value from app.yaml file (flag may be
repeated to set multiple variables).
-R, --allow_any_runtime
Do not validate the runtime in app.yaml
--oauth2 Ignored (OAuth2 is the default).
--oauth2_refresh_token=OAUTH2_REFRESH_TOKEN
An existing OAuth2 refresh token to use. Will not
attempt interactive OAuth approval.
--oauth2_access_token=OAUTH2_ACCESS_TOKEN
An existing OAuth2 access token to use. Will not
attempt interactive OAuth approval.
--authenticate_service_account
Authenticate using the default service account for the
Google Compute Engine VM in which appcfg is being
called
--noauth_local_webserver
Do not run a local web server to handle redirects
during OAuth authorization.
我终于找到了真正的原因,这不是AppEngine SDK的错误。而是我的 Python 解释器,因为我注意到它不接受任何 .py 文件的参数。原来是注册表错误,位于[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command]
,我不得不将值从"C:\Python27\python.exe" "%1"
更改为 "C:\Python27\python.exe" "%1" %*
这是怎么发生的,无论是 Python 2.7 安装程序,还是 AppEngine SDK,我都不确定。
我遇到了这个问题,并且在与 App Engine python 版本不同的局部变量 python 版本中加深了。
所以解决方案就是在脚本之前添加当前 python 版本位置:
C:\Python27\python.exe "C:\Program Files (x86)\Google\google_appengine\appcfg.py"
而且 return 效果很好。
我只是有点难以理解为什么要执行此命令:
>appcfg.py -A adept-box-109804 update app.yaml
Try Google App Engine Now 页面给出的内容不起作用。我已经为 Python 下载了 App Engine SDK,并将 Path 设置为指向 appcfg.py 的位置,但是我的项目根目录中的 运行 appcfg.py 不起作用在命令行中。我要么必须导航到包含 appcfg.py 的文件夹并执行
>python appcfg.py help
或者
>python "C:\Program Files (x86)\Google\google_appengine\appcfg.py" help
让命令可以在任何地方工作。我使用后一种方法来部署我的测试应用程序,但只是想知道是否有人可以解释为什么简单 Google 教程给出的命令没有执行任何操作。我还检查以确保使用 Python 2.7 解释器自动打开 .py 文件,以便只需在命令行中键入
即可执行文件 hello.py>hello.py
它会输出它的打印语句。另一方面,无论参数如何,以类似的方式使用 appcfg.py 都会得到相同的输出(请注意我截断了输出,但请放心,无论参数如何,它们都是相同的:
C:\>appcfg.py help backends
Usage: appcfg.py [options] <action>
Action must be one of:
backends: Perform a backend action.
backends configure: Reconfigure a backend without stopping it.
backends delete: Delete a backend.
backends list: List all backends configured for the app.
backends rollback: Roll back an update of a backend.
backends start: Start a backend.
backends stop: Stop a backend.
backends update: Update one or more backends.
create_bulkloader_config: Create a bulkloader.yaml from a running application.
cron_info: Display information about cron jobs.
delete_version: Delete the specified version for an app.
download_app: Download a previously-uploaded app.
download_data: Download entities from datastore.
help: Print help for a specific action.
list_versions: List all uploaded versions for an app.
request_logs: Write request logs in Apache common log format.
resource_limits_info: Get the resource limits.
rollback: Rollback an in-progress update.
set_default_version: Set the default (serving) version.
start_module_version: Start a module version.
stop_module_version: Stop a module version.
update: Create or update an app version.
update_cron: Update application cron definitions.
update_dispatch: Update application dispatch 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.
C:\>appcfg.py help update
Usage: appcfg.py [options] <action>
Action must be one of:
backends: Perform a backend action.
backends configure: Reconfigure a backend without stopping it.
backends delete: Delete a backend.
backends list: List all backends configured for the app.
backends rollback: Roll back an update of a backend.
backends start: Start a backend.
backends stop: Stop a backend.
backends update: Update one or more backends.
create_bulkloader_config: Create a bulkloader.yaml from a running application.
cron_info: Display information about cron jobs.
delete_version: Delete the specified version for an app.
download_app: Download a previously-uploaded app.
download_data: Download entities from datastore.
help: Print help for a specific action.
list_versions: List all uploaded versions for an app.
request_logs: Write request logs in Apache common log format.
resource_limits_info: Get the resource limits.
rollback: Rollback an in-progress update.
set_default_version: Set the default (serving) version.
start_module_version: Start a module version.
stop_module_version: Stop a module version.
update: Create or update an app version.
update_cron: Update application cron definitions.
update_dispatch: Update application dispatch 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.
您的困惑可能源于混淆了 2 种可能的调用样式:
python appcfg.py ...
appcfg.py ...
第一个无法利用 appcfg.py
的位置在路径中这一事实,它只是 python
可执行文件的参数,无法定位appcfg.py
文件,除非:
- 它在当前目录中找到它
appcfg.py
文件使用完整路径或相对于调用python
的当前工作目录的路径指定
这就是您的第 2 条和第 3 条命令无法按预期工作的原因。如果 appcfg.py
的位置在路径中,则使用第二种调用方式应该有效——就像你最后一次调用命令一样。
要记住的要点:路径配置仅适用于命令可执行文件,而不适用于其参数(顺便说一句,每个可执行文件都可以按照自己的意愿进行处理,some 可执行文件可能将参数与路径配置相结合以获得文件的位置。
同样,appcfg.py
本身(一旦使用 2 种调用方式中的任何一种成功调用)需要能够找到指定为参数的 app.yaml
文件。它不能这样做,除非:
- 它在当前目录中找到它
- 使用完整路径或相对于调用
appcfg.py
的当前工作目录的路径指定app.yaml
文件(或其目录)
我怀疑 appcfg.py
无法找到您的 app.yaml
文件可能是您提到的第一个命令不起作用的原因。如果不是,您应该提供有关失败的详细信息。
关于为什么无论参数如何,最后一个命令的输出都是相同的,我不确定,这可能是 SDK windows 版本中的错误。在 linux 中输出不同:
> appcfg.py help backends
Usage: appcfg.py [options] backends <directory> <action>
Perform a backend action.
The 'backends' command will perform a backends action.
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
The App Engine server.
-e EMAIL, --email=EMAIL
The username to use. Will prompt if omitted.
-H HOST, --host=HOST Overrides the Host header sent with all RPCs.
--no_cookies Do not save authentication cookies to local disk.
--skip_sdk_update_check
Do not check for SDK updates.
-A APP_ID, --application=APP_ID
Set the application, overriding the application value
from app.yaml file.
-M MODULE, --module=MODULE
Set the module, overriding the module value from
app.yaml.
-V VERSION, --version=VERSION
Set the (major) version, overriding the version value
from app.yaml file.
-r RUNTIME, --runtime=RUNTIME
Override runtime from app.yaml file.
-E NAME:VALUE, --env_variable=NAME:VALUE
Set an environment variable, potentially overriding an
env_variable value from app.yaml file (flag may be
repeated to set multiple variables).
-R, --allow_any_runtime
Do not validate the runtime in app.yaml
--oauth2 Ignored (OAuth2 is the default).
--oauth2_refresh_token=OAUTH2_REFRESH_TOKEN
An existing OAuth2 refresh token to use. Will not
attempt interactive OAuth approval.
--oauth2_access_token=OAUTH2_ACCESS_TOKEN
An existing OAuth2 access token to use. Will not
attempt interactive OAuth approval.
--authenticate_service_account
Authenticate using the default service account for the
Google Compute Engine VM in which appcfg is being
called
--noauth_local_webserver
Do not run a local web server to handle redirects
during OAuth authorization.
我终于找到了真正的原因,这不是AppEngine SDK的错误。而是我的 Python 解释器,因为我注意到它不接受任何 .py 文件的参数。原来是注册表错误,位于[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command]
,我不得不将值从"C:\Python27\python.exe" "%1"
更改为 "C:\Python27\python.exe" "%1" %*
这是怎么发生的,无论是 Python 2.7 安装程序,还是 AppEngine SDK,我都不确定。
我遇到了这个问题,并且在与 App Engine python 版本不同的局部变量 python 版本中加深了。 所以解决方案就是在脚本之前添加当前 python 版本位置:
C:\Python27\python.exe "C:\Program Files (x86)\Google\google_appengine\appcfg.py"
而且 return 效果很好。