Python 我应该在开发服务器上为Google应用程序引擎BulkLoader输入哪些凭据?

Python 我应该在开发服务器上为Google应用程序引擎BulkLoader输入哪些凭据?,python,google-app-engine,Python,Google App Engine,我想问一下,在使用Google App Engine BulkLoader类导入数据时,需要使用哪种凭据 appcfg.py upload_data --config_file=models.py --filename=listcountries.csv --kind=CMSCountry --url=http://localhost:8178/remote_api vit/ 然后它要求我提供凭证: 请输入的登录凭据 本地主机 这里是models.py内容的提取,我使用这个文件 每次尝试输入电

我想问一下,在使用Google App Engine BulkLoader类导入数据时,需要使用哪种凭据

appcfg.py upload_data --config_file=models.py --filename=listcountries.csv --kind=CMSCountry --url=http://localhost:8178/remote_api vit/
然后它要求我提供凭证:

请输入的登录凭据 本地主机

这里是models.py内容的提取,我使用这个文件

每次尝试输入电子邮件和密码都会导致“身份验证失败”,因此我无法将数据导入开发服务器

我认为我的文件和模型没有任何问题,因为我已成功地将数据上传到appspot.com应用程序。
那么,我应该为本地主机凭据输入什么?
我还尝试将Eclipse与Pydev一起使用,但仍然得到了相同的消息:(
以下是输出:

Uploading data records.
[INFO    ] Logging to bulkloader-log-20090820.121659
[INFO    ] Opening database: bulkloader-progress-20090820.121659.sql3
[INFO    ] [Thread-1] WorkerThread: started
[INFO    ] [Thread-2] WorkerThread: started
[INFO    ] [Thread-3] WorkerThread: started
[INFO    ] [Thread-4] WorkerThread: started
[INFO    ] [Thread-5] WorkerThread: started
[INFO    ] [Thread-6] WorkerThread: started
[INFO    ] [Thread-7] WorkerThread: started
[INFO    ] [Thread-8] WorkerThread: started
[INFO    ] [Thread-9] WorkerThread: started
[INFO    ] [Thread-10] WorkerThread: started
Password for foobar@nowhere.com: [DEBUG   ] Configuring remote_api. url_path = /remote_api, servername = localhost:8178

[DEBUG   ] Bulkloader using app_id: abc
[INFO    ] Connecting to /remote_api
[ERROR   ] Exception during authentication
Traceback (most recent call last):
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\tools\bulkloader.py", line 2802, in Run
request_manager.Authenticate()
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\tools\bulkloader.py", line 1126, in Authenticate
remote_api_stub.MaybeInvokeAuthentication()
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 488, in MaybeInvokeAuthentication
datastore_stub._server.Send(datastore_stub._path, payload=None)
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\tools\appengine_rpc.py", line 344, in Send
f = self.opener.open(req)
  File "C:\Python25\lib\urllib2.py", line 381, in open
response = self._open(req, data)
  File "C:\Python25\lib\urllib2.py", line 399, in _open
'_open', req)
  File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 1107, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python25\lib\urllib2.py", line 1082, in do_open
raise URLError(err)
URLError: <urlopen error (10061, 'Connection refused')>
[INFO    ] Authentication Failed
上传数据记录。
[信息]记录到bulkloader-log-20090820.121659
[信息]打开数据库:bulkloader-progress-20090820.121659.sql3
[INFO][Thread-1]WorkerThread:已启动
[INFO][Thread-2]WorkerThread:已启动
[INFO][Thread-3]WorkerThread:已启动
[INFO][Thread-4]WorkerThread:已启动
[INFO][Thread-5]WorkerThread:已启动
[INFO][Thread-6]WorkerThread:已启动
[INFO][Thread-7]WorkerThread:已启动
[INFO][Thread-8]WorkerThread:已启动
[INFO][Thread-9]WorkerThread:已启动
[INFO][Thread-10]WorkerThread:已启动
密码foobar@nowhere.com:[DEBUG]配置远程\u api.url\u路径=/remote\u api,服务器名=本地主机:8178
[调试]使用app_id:abc的散货加载器
[信息]连接到/远程\u api
验证期间发生[错误]异常
回溯(最近一次呼叫最后一次):
文件“D:\Projects\GoogleAppEngine\google\u appengine\google\appengine\tools\bulkloader.py”,第2802行,正在运行
请求\u管理器。身份验证()
文件“D:\Projects\GoogleAppEngine\google\u appengine\google\appengine\tools\bulkloader.py”,第1126行,在“身份验证”中
远程api存根.MaybeInvokeAuthentication()
文件“D:\Projects\GoogleAppEngine\google\u appengine\google\appengine\ext\remote\u api\remote\u api\u stub.py”,第488行,在MaybeInvokeAuthentication中
数据存储\u存根.\u服务器.Send(数据存储\u存根.\u路径,有效负载=无)
文件“D:\Projects\GoogleAppEngine\google\u appengine\google\appengine\tools\appengine\u rpc.py”,第344行,在Send中
f=自动开启器开启(要求)
文件“C:\Python25\lib\urllib2.py”,第381行,打开
响应=自身打开(请求,数据)
文件“C:\Python25\lib\urllib2.py”,第399行,处于打开状态
"开放",
文件“C:\Python25\lib\urllib2.py”,第360行,在调用链中
结果=func(*args)
文件“C:\Python25\lib\urllib2.py”,第1107行,在http\u open中
返回self.do_open(httplib.HTTPConnection,req)
文件“C:\Python25\lib\urllib2.py”,第1082行,在do_open中
引发URL错误(err)
URL错误:
[信息]身份验证失败

谢谢大家!

我建议您遵循给出的建议,我引用:

将此添加到app.yaml文件:

-- url: /loadusers
 script: myloader.py
 login: admin
请注意,如果在本地计算机上运行它 开发机器,注释掉 最后一行登录:admin,以便您 不需要凭据来运行 散装装载机

(我的重点)。

下一步对我有用:

  • 删除线路

    login:admin
    
    来自app.yaml

  • 正在更新应用程序cofig:

    appcfg.py update [app-id]
    
  • (重新)启动本地服务器:

    appserver [app-id] 
    
  • 上载数据:

    appcfg.py upload_data --config_file=album_loader.py --filename album_data.csv --kind Album --url=http://localhost:8080/remote_api ../[app-id] 
    
    询问邮件和密码键入任何内容


编辑:查看我的新解决方案

这个问题仍然存在。我已经打开询问是否可以绕过本地dev服务器上的身份验证。请投票支持这个问题,以便我们[迅速]解决它

我已经能够通过以下方式将数据上载到dev服务器:

  • 离开app.yaml中的“login:admin”行
  • 添加“--电子邮件=foobar@nowhere.com“听从你的命令
  • 提示输入密码时按Enter键(无需任何设置)
离开“login:admin”行是一件好事,因为如果没有这一行,您将无法在生产服务器上上载应用程序,这可能会使您暴露在向数据存储添加数据的人面前

大宗报价


是,注释掉远程api的管理要求:

[app.yaml] -url:/remote\u api 脚本:$PYTHON_LIB/google/appengine/ext/remote_api/handler.py #登录名:admin

然后运行以下命令:

$bulkloader.py--dump--kind=DbMyKind--url=--filename=export.csv--app\u id=my\u appid--auth\u domain=localhost:8080


注意:验证是否传递了--auth_域,并且为本地主机传递了正确的端口。

您需要首先在本地开发服务器中创建管理员凭据

当您的firefox(或chrome safari等)打开时,系统将要求您登录(无密码),输入一封电子邮件作为您的登录名,然后勾选
以管理员身份登录
框,登录。这将为您创建本地管理员凭据,在本地批量加载时使用此凭据

它适用于其他管理员要求的本地访问


不使用(或注释)登录名:admin是一种不好的做法,因为您可能也会将其部署到生产中。保重

EUREKA:我找到了使用
bulkloader.py
工具而无需手动输入登录凭据的方法

以下是两个步骤:


设置你的
app.yaml
文件。例如:

- url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py # login: admin 您应该将它放在
app.yaml
中的
-url:.*
行之前,否则您将永远无法访问
/remote\u api
url

请注意,我留下了
login:admin
部分,因为删除它是一种非常糟糕的做法,因为您可能会将其部署到生产环境中


2启动此命令(使其适应您的需要)

诀窍是使用这两个参数的组合:

  • --email=
    (你可以输入你想要的任何电子邮件地址,我使用
    foobar@nowhere.com
  • --passin
指定 - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py # login: admin $ bulkloader.py --dump --kind=DbMyKind --url=http://localhost:8080/remote_api --filename=export.csv --app_id=my_appid --auth_domain=localhost:8080
- url: /remote_api
  script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
  login: admin
echo 'XX' | python2.5 ../google_appengine/bulkloader.py --dump --kind=NAMEOFMODEL --url=http://localhost:8080/remote_api --filename=FILENAME --app_id=APPID --email=foobar@nowhere.com --passin .
manage.py dumpdata >dump.json
manage.py remote loaddata dump.json