python - 使用 appcfg.py App Engine 1.8 for python 上传数据时出现错误 301/404

标签 python google-app-engine

App Engine SDK 中的 7.5 到 1.8,现在我无法上传数据。 这是错误:

appcfg.py upload_data --url=http://192.168.1.106:8001/ --filename=database --num_threads=4 --rps_limit=500
08:46 PM Uploading data records.
[INFO    ] Logging to bulkloader-log-20130528.204655
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 500/second
[INFO    ] Batch Size: 10
Error 301: --- begin server output ---

--- end server output ---

当我使用:/_ah/remote_api 时,这是错误。

appcfg.py upload_data --url=http://192.168.1.106:8001/_ah/remote_api --filename=database --num_threads=4 --rps_limit=500
08:48 PM Uploading data records.
[INFO    ] Logging to bulkloader-log-20130528.204813
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 500/second
[INFO    ] Batch Size: 10
Error 404: --- begin server output ---
404 Not Found
The resource could not be found.

--- end server output ---

我已经使用localhost(使用默认配置)对其进行了测试,结果完全相同。 为什么 1.7.5 版本可以正常工作,但 1.8 版本却无法工作? 有什么想法吗?

编辑: 我也用bulkloader进行了测试,以使事情变得更容易,这就是结果:

1) 我已使用以下命令将数据库转储到 GAE 中的应用程序中:

bulkloader.py --dump --url=<myapp> --filename=dumpBetaServer 

一切都很好。我有一个名为 dumpBetaServer 的转储。

2)现在,我尝试将此转储恢复到我的开发服务器:

bulkloader.py --restore --url=http://192.168.1.106:8001 --filename=dumpBetaServer --num_threads=1

这就是结果:

[INFO    ] Logging to bulkloader-log-20130529.081227
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
Traceback (most recent call last):
  File "/usr/local/bin/bulkloader.py", line 171, in <module>
    run_file(__file__, globals())
  File "/usr/local/bin/bulkloader.py", line 167, in run_file
    execfile(script_path, globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4401, in <module>
    sys.exit(main(sys.argv))
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4397, in main
    return _PerformBulkload(arg_dict)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4165, in _PerformBulkload
    throttle_class=throttle_class)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4072, in _GetRemoteAppId
    rpc_server_factory=throttled_rpc_server_factory, secure=secure)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 659, in GetRemoteAppId
    app_id = GetRemoteAppIdFromServer(server, path, rtok)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 568, in GetRemoteAppIdFromServer
    response = server.Send(path, payload=None, **urlargs)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 301: Moved Permanently

当我尝试使用其他命令时:

bulkloader.py --restore --url=http://192.168.1.106:8001/_ah/remote_api --filename=dumpBetaServer --num_threads=1

这是结果:

[INFO    ] Logging to bulkloader-log-20130529.081755
[INFO    ] Throttling transfers:
[INFO    ] Bandwidth: 250000 bytes/second
[INFO    ] HTTP connections: 8/second
[INFO    ] Entities inserted/fetched/modified: 20/second
[INFO    ] Batch Size: 10
Traceback (most recent call last):
  File "/usr/local/bin/bulkloader.py", line 171, in <module>
    run_file(__file__, globals())
  File "/usr/local/bin/bulkloader.py", line 167, in run_file
    execfile(script_path, globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4401, in <module>
    sys.exit(main(sys.argv))
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4397, in main
    return _PerformBulkload(arg_dict)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4165, in _PerformBulkload
    throttle_class=throttle_class)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/bulkloader.py", line 4072, in _GetRemoteAppId
    rpc_server_factory=throttled_rpc_server_factory, secure=secure)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 659, in GetRemoteAppId
    app_id = GetRemoteAppIdFromServer(server, path, rtok)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 568, in GetRemoteAppIdFromServer
    response = server.Send(path, payload=None, **urlargs)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

编辑2: 这是我的 app.yaml

#  For Google App Engine deployment, copy this file to app.yaml
#  and edit as required
#  See http://code.google.com/appengine/docs/python/config/appconfig.html
#  and http://web2py.com/book/default/chapter/11?search=app.yaml

application: <myapp>
version: 31
api_version: 1

# use this line for Python 2.5
#
runtime: python

# use these lines for Python 2.7
# upload app with: appcfg.py update web2py (where 'web2py' is web2py's root directory)
#
# runtime: python27
# threadsafe: true    # true for WSGI & concurrent requests (Python 2.7 only)

default_expiration: "24h"   # for static files

handlers:

- url: /(?P<a>.+?)/static/(?P<b>.+)
  static_files: applications/\1/static/\2
  upload: applications/(.+?)/static/(.+)
  secure: always

- url: /favicon.ico
  static_files: applications/welcome/static/favicon.ico
  upload: applications/welcome/static/favicon.ico

- url: /robots.txt
  static_files: applications/welcome/static/robots.txt
  upload: applications/welcome/static/robots.txt

- url: .*
  script: gaehandler.py         # CGI
#  script: gaehandler.wsgiapp    # WSGI (Python 2.7 only)
  secure: optional

admin_console:
  pages:
  - name: Appstats
    url: /_ah/stats


builtins:
- remote_api: on
- appstats: on
- admin_redirect: on
- deferred: on

感谢您的帮助!

最佳答案

新的 devappserver 在不同的端口启动不同的服务。一般情况下,它将启动三个服务:您的应用程序(默认服务器)、管理服务器(相当于 appengine.google.com 上的管理控制台)和 API 服务器。日志将显示如下内容:

INFO 2013-05-31 16:34:58,397 api_server.py:148] Starting API server at: http://localhost:48392

INFO 2013-05-31 16:34:58,408 dispatcher.py:96] Starting server "default" running at: http://localhost:8080

INFO 2013-05-31 16:34:58,420 admin_server.py:112] Starting admin server at: http://localhost:8000

您需要传递给批量 uploader 的网址是您的应用程序的网址(默认服务器)。

关于python - 使用 appcfg.py App Engine 1.8 for python 上传数据时出现错误 301/404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16799372/

相关文章:

google-app-engine - 带有 Google Domain 的 Google Cloud,静态网站 ssl 证书无效

python - 如何检测 Python 中的伪控制台以激活着色?

python pytest 偶尔会因 OSError : reading from stdin while output is captured 而失败

基于 Python 的作业调度程序,具有依赖性解析

java - maven-gae-plugin,如何将我的类打包为 JAR?

python - App Engine - 在运行时指定实体名称

javascript - 无法使用 Stripe 创建信用卡 token (django)

python - 将 numpy 字符串数组转换为 base-16 中的整数

google-app-engine - 去,Appengine,SMTP,Gmail

python - 谷歌应用引擎: "Cannot create a file when that file already exists"