appcfg.py不能在命令行中工作 [英] appcfg.py not working in command line

查看:206
本文介绍了appcfg.py不能在命令行中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 > appcfg.py -A adept- box-109804更新app.yaml 

由Try Google App Engine Now页面不起作用。我已经下载了适用于Python的App Engine SDK,并将Path设置为指向appcfg.py的位置,但在项目根目录中运行appcfg.py在命令行中不起作用。我必须导航到包含appcfg.py的文件夹并执行

 > python appcfg.py help 

或者做

  > pythonC:\ Program Files(x86)\Google\google_appengine\appcfg.pyhelp 

可以从任何地方获得命令。我使用后一种方法来部署我的测试应用程序,但只是想知道是否有人能解释为什么简单的Google教程给出的命令没有做任何事情。我还检查了一下,确保.py文件可以用Python 2.7解释器自动打开,这样只需输入



<$就可以在命令行中执行hello.py文件p $ p> > hello.py

声明。另一方面,使用appcfg.py以类似的方式给出相同的输出,无论参数如何(请注意我截断了输出,但请放心,无论参数如何,它们都是相同的):

  C:\> appcfg.py帮助后端
用法:appcfg.py [选项]<操作>

Action必须是以下之一:
后端:执行后端操作
后端configure:重新配置后端而不停止它
后端删除:删除后端
后端列表:列表所有为应用程序配置的后端
backends rollback:回退后端的更新
后端start:启动后端
后端stop:停止后端
后端更新:更新一个或多个后端
create_bulkloader_config:从正在运行的应用程序创建bulkloader.yaml
cron_info:显示有关cron作业的信息
delete_version:删除应用程序的指定版本
download_app:下载一个previ呃上传的应用程序。
download_data:从数据存储下载实体。
help:为特定操作打印帮助。
list_versions:列出应用程序的所有上传版本。
request_logs:以Apache公用日志格式写请求日志。
resource_limits_info:获取资源限制。
回滚:回滚正在进行的更新。
set_default_version:设置默认(服务)版本。
start_module_version:启动模块版本。
stop_module_version:停止模块版本。
更新:创建或更新应用程序版本。
update_cron:更新应用程序的cron定义。
update_dispatch:更新应用程序分派定义。
update_dos:更新应用程序的dos定义。
update_indexes:更新应用程序索引。
update_queues:更新应用程序任务队列定义。
upload_data:将数据记录上传到数据存储。
vacuum_indexes:从应用程序中删除未使用的索引。
使用'help< action>'获取详细描述。

C:\> appcfg.py帮助更新
用法:appcfg.py [options]< action>

操作必须是以下之一:
后端:执行后端操作。
后端配置:重新配置后端而不停止它。
后端删除:删除后端。
后端列表:列出为应用程序配置的所有后端。
backends rollback:回退后端的更新。
后端开始:开始一个后端。
后端停止:停止后端。
后端更新:更新一个或多个后端。
create_bulkloader_config:从正在运行的应用程序创建bulkloader.yaml。
cron_info:显示有关cron作业的信息。
delete_version:删除应用程序的指定版本。
download_app:下载以前上传的应用程序。
download_data:从数据存储下载实体。
help:为特定操作打印帮助。
list_versions:列出应用程序的所有上传版本。
request_logs:以Apache公用日志格式写请求日志。
resource_limits_info:获取资源限制。
回滚:回滚正在进行的更新。
set_default_version:设置默认(服务)版本。
start_module_version:启动模块版本。
stop_module_version:停止模块版本。
更新:创建或更新应用程序版本。
update_cron:更新应用程序的cron定义。
update_dispatch:更新应用程序分派定义。
update_dos:更新应用程序的dos定义。
update_indexes:更新应用程序索引。
update_queues:更新应用程序任务队列定义。
upload_data:将数据记录上传到数据存储。
vacuum_indexes:从应用程序中删除未使用的索引。
使用'help< action>'获取详细描述。


解决方案

您的困惑可能源自混合2种可能的调用样式:


  1. python appcfg.py ...

  2. appcfg.py ...

第一个可以没有利用 appcfg.py 位于路径中的事实,它只是 python 可执行文件,无法找到 appcfg.py 文件:




  • 它在当前目录中找到

  • appcfg.py 文件是使用完整路径或相对于调用 python 的当前工作目录



这就是为什么你的第二和第三个命令不能像你期望的那样工作。如果 appcfg.py 的位置在路径中,则使用第二种调用方式应该可以工作 - 就像您上次执行的命令一样。



要记住的关键点:路径配置仅适用于命令可执行文件,而不适用于其参数(每个可执行文件可能按照自己的意愿处理的BTW 可执行文件可能将参数与路径配置结合起来以获取文件的位置)。



同样 appcfg.py 本身(一次使用2种调用样式中的任何一种成功调用)需要能够定位指定为参数的 app.yaml 文件。它不能这样做,除非:




  • 它在当前目录中找到它

  • app.yaml 文件(或其目录)使用完整路径或相对于当前工作目录的路径来指定 appcfg.py 被调用



我怀疑 appcfg.py 无法找到您的 app.yaml 文件可能是您提到的第一条命令不起作用的原因。如果不是,你应该提供关于失败的细节。



关于为什么最后一个命令的输出是相同的,无论参数如何,我不确定,它可能是错误在SDK的Windows版本中。在linux中,输出是不同的:

 > appcfg.py help backends 
用法:appcfg.py [options]后端<目录> <作用>

执行后端操作。

'后端'命令将执行后端操作。

选项:
-h,--help显示帮助信息并退出。
-q,--quiet仅打印错误。
-v,--verbose打印信息级别日志。
- 打印所有日志。
-s SERVER,--server = SERVER
App Engine服务器。
-e EMAIL,--email = EMAIL
要使用的用户名。将提示如果省略。
-H HOST,--host = HOST覆盖所有RPC发送的主机头。
--no_cookies不要将认证cookie保存到本地磁盘。
--skip_sdk_update_check
不检查SDK更新。
-A APP_ID,--application = APP_ID
设置应用程序,覆盖app.yaml文件中的应用程序值

-M MODULE,--module = MODULE
设置模块,覆盖
app.yaml中的模块值。
-V VERSION,--version = VERSION
设置(主要)版本,覆盖app.yaml文件中的版本值

-r RUNTIME,--runtime = RUNTIME
从app.yaml文件覆盖运行时间。
-E NAME:VALUE,--env_variable = NAME:VALUE
设置一个环境变量,可能会覆盖app.yaml文件中的
env_variable值(标志可能是
重复设置多个变量)。
-R,--allow_any_runtime
不验证app.yaml中的运行时间
--oauth2忽略(OAuth2是默认值)。
--oauth2_refresh_token = OAUTH2_REFRESH_TOKEN
要使用的现有OAuth2刷新标记。
不会尝试交互式OAuth审批。
--oauth2_access_token = OAUTH2_ACCESS_TOKEN
要使用的现有OAuth2访问令牌。
不会尝试交互式OAuth审批。
--authenticate_service_account
使用
Google Compute Engine VM的默认服务帐户进行身份验证,其中appcfg为
,名称为
--noauth_local_webserver
在OAuth授权期间运行本地Web服务器来处理重定向


I'm just having a bit of trouble understanding why this command:

>appcfg.py -A adept-box-109804 update app.yaml

as given by the Try Google App Engine Now page does not work. I have downloaded the App Engine SDK for Python, and have Path set up to point to the location of appcfg.py, but running appcfg.py in my projects root directory does not work in the command line. I either have to navigate to the folder containing appcfg.py and do

>python appcfg.py help

or do

>python "C:\Program Files (x86)\Google\google_appengine\appcfg.py" help

to get a command to work from anywhere. I used the latter method to deploy my test app, but was just wondering if someone could explain why the command as given by the simple Google tutorial did not do anything. I also checked to make sure that .py files are automatically opened with the Python 2.7 interpreter, such that a file hello.py will be executed in the command line by simply typing

>hello.py

and it will output its print statement. On the other hand, using appcfg.py in a similar manner gives the same output no matter the arguments (please note I truncated the output, but rest assured that they are identical no matter the arguments:

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.

解决方案

Your confusion probably stems from mixing up 2 possible invocations styles:

  1. python appcfg.py ...
  2. appcfg.py ...

The 1st one can't make use of the fact that the location of the appcfg.py is in the path, it is just an argument to the python executable, which can not locate the appcfg.py file unless either:

  • it finds it in the current directory
  • the appcfg.py file is specified using a full path or a path relative to the current working directory from which python is invoked

This is the reason for which your 2nd and 3rd commands don't work as you'd expect. Using the 2nd invocation style instead should work if the location of the appcfg.py is in the path - just as your last command invocation does.

Key point to remember: the path configuration applies to the command executable only, not to its arguments (which BTW each executable may process as it wishes, some executables may combine arguments with the path configuration to obtain location of files).

Similarly appcfg.py itself (once successfully invoked using either of the 2 invocation styles) needs to be able to locate your app.yaml file specified as argument. It cannot do so unless either:

  • it finds it in the current directory
  • the app.yaml file (or its directory) is specified using a full path or a path relative to the current working directory from which appcfg.py is invoked

I suspect appcfg.py's inability to locate your app.yaml file may be the reason for which the 1st command you mentioned didn't work. If not you should provide details about the failure.

Regarding why the output of your last command is identical regardless of the arguments, I'm not sure, it could be a bug in the windows version of the SDK. In linux the output is different:

> 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.

这篇关于appcfg.py不能在命令行中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆