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

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

问题描述

我只是在理解这个命令的原因时遇到了一些麻烦:

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

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

由立即试用 Google App Engine 页面提供的信息不起作用.我已经下载了适用于 Python 的 App Engine SDK,并将路径设置为指向 appcfg.py 的位置,但是在我的项目根目录中运行 appcfg.py 在命令行中不起作用.我要么必须导航到包含 appcfg.py 的文件夹并执行

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

或者做

>python "C:Program Files (x86)Googlegoogle_appengineappcfg.py" help

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

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

并且它会输出它的打印语句.另一方面,无论参数如何,以类似方式使用 appcfg.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.

推荐答案

您的困惑可能源于混淆了 2 种可能的调用样式:

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

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

第一个不能利用 appcfg.py 的位置在路径中这一事实,它只是 python 可执行文件的一个参数,它无法找到 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:

  • 它在当前目录中找到它
  • appcfg.py 文件是使用完整路径或相对于调用 python 的当前工作目录的路径指定的
  • 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

这就是您的第二个和第三个命令无法按预期工作的原因.如果 appcfg.py 的位置在路径中,则使用第二个调用样式应该可以工作 - 就像您上次调用的命令一样.

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

类似地,appcfg.py 本身(一旦使用两种调用样式中的任何一种成功调用)需要能够找到指定为参数的 app.yaml 文件.它不能这样做,除非:

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:

  • 它在当前目录中找到它
  • app.yaml 文件(或其目录)使用完整路径或相对于调用 appcfg.py 的当前工作目录的路径指定
  • 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

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

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.

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

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天全站免登陆