2015-10-14 36 views
2

工作,我只是有一點麻煩理解爲什麼這個命令:appcfg.py不是在命令行

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

由試用谷歌應用程序引擎現在頁面給出不起作用。我已經下載了適用於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教程給出的命令沒有做任何事情。我還檢查只需輸入

>hello.py 

確保.py文件會自動使用Python 2.7解釋器打開,使得文件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. 

回答

3

你的困惑大概是從2種可能的調用風格混合了莖:

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

釷Ë一日一不能使用的事實appcfg.py的位置是在路徑,它只是一個參數傳遞給python可執行文件,除非要麼無法找到appcfg.py文件:

  • 發現它在當前目錄
  • appcfg.py文件使用完整路徑或相對於從python調用

這對於你的第二個和第三個命令不要」的原因當前工作目錄的路徑指定不像你期望的那樣工作。如果appcfg.py的位置在路徑中,則使用第二種調用樣式應該可以工作 - 就像您上次執行的命令一樣。

關鍵點要記住:路徑配置適用於可執行的命令而已,並不是它的參數(這BTW每個可執行文件可以處理,因爲它希望,一些可執行可以與路徑配置,以獲得位置結合參數的文件)。

同樣,appcfg.py本身(一次使用2種調用樣式中的任何一種調用成功)需要能夠找到指定爲參數的app.yaml文件。它不能這樣做,除非兩種:

  • 它發現它在使用完整路徑或相對於當前工作目錄的路徑從appcfg.py是指定了當前目錄
  • app.yaml文件(或它的目錄)調用

我懷疑appcfg.py的無法找到您app.yaml文件可能是你提到的1號命令沒有工作的原因。如果不是,你應該提供有關失敗的細節。

關於爲什麼最後一條命令的輸出與參數無關,我不確定,它可能是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. 
+0

感謝您的簡潔明確的答案,丹。我也懷疑,當使用appcfg.py調用時,相同的輸出是Windows版本的錯誤。幸運的是,關閉appcfg的全部功能仍然可以通過使用python appcfg.py調用來訪問。 – TowMater7

+0

這可以解釋爲什麼這個bug不被注意到發佈的SDK版本:) –

5

我終於找到了真正的原因,它不是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 ,但我不確定。

+0

它也適用於我! – Suriyaa