I would like to ask which kind of credentials do I need to put on for importing data using the Google App Engine BulkLoader class
我想问一下,使用Google App Engine BulkLoader类导入数据需要使用哪种凭据
appcfg.py upload_data --config_file=models.py --filename=listcountries.csv --kind=CMSCountry --url=http://localhost:8178/remote_api vit/
And then it asks me for credentials:
然后它要求我提供证书:
Please enter login credentials for localhost
请输入localhost的登录凭据
Here is an extraction of the content of the models.py, I use this listcountries.csv file
这是一个models.py内容的提取,我使用这个listcountries.csv文件
class CMSCountry(db.Model):
sortorder = db.StringProperty()
name = db.StringProperty(required=True)
formalname = db.StringProperty()
type = db.StringProperty()
subtype = db.StringProperty()
sovereignt = db.StringProperty()
capital = db.StringProperty()
currencycode = db.StringProperty()
currencyname = db.StringProperty()
telephonecode = db.StringProperty()
lettercode = db.StringProperty()
lettercode2 = db.StringProperty()
number = db.StringProperty()
countrycode = db.StringProperty()
class CMSCountryLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'CMSCountry',
[('sortorder', str),
('name', str),
('formalname', str),
('type', str),
('subtype', str),
('sovereignt', str),
('capital', str),
('currencycode', str),
('currencyname', str),
('telephonecode', str),
('lettercode', str),
('lettercode2', str),
('number', str),
('countrycode', str)
])
loaders = [CMSCountryLoader]
Every tries to enter the email and password result in "Authentication Failed", so I could not import the data to the development server.
每次尝试输入电子邮件和密码都会导致“身份验证失败”,因此我无法将数据导入开发服务器。
I don't think that I have any problem with my files neither my models because I have successfully uploaded the data to the appspot.com application.
So what should I put in for localhost credentials?
I also tried to use Eclipse with Pydev but I still got the same message :(
Here is the output:
我不认为我的文件有任何问题,因为我已成功将数据上传到appspot.com应用程序。那么我应该为localhost凭据添加什么?我也尝试使用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
Thank you!
9 个解决方案
#1
4
I recommend you follow the advice given here, and I quote:
我建议你按照这里给出的建议,我引用:
add this to app.yaml file:
将此添加到app.yaml文件:
-- url: /loadusers script: myloader.py login: admin
Note that if you run it on local development machine, comment off the last line login:admin so that you don't need a credential to run the bulkloader.
请注意,如果您在本地开发计算机上运行它,请注释掉最后一行login:admin,这样您就不需要凭据来运行bulkloader。
(my emphasis).
#2
6
EUREKA: I found the way to use the bulkloader.py
tool without having to manually enter login credentials.
EUREKA:我找到了使用bulkloader.py工具的方法,而无需手动输入登录凭据。
Here are the 2 steps:
以下是两个步骤:
Set your app.yaml
file up. Example:
设置app.yaml文件。例:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
You should put it BEFORE your - url: .*
line in app.yaml
, otherwise you will never access the /remote_api
url.
你应该把它放在app.yaml中你的 - url:。*行之前,否则你永远不会访问/ remote_api网址。
Note that I've left the login: admin
part, as removing it is a VERY BAD practice, since you might deploy that into production...
请注意,我已经离开了login:admin部分,因为删除它是一种非常糟糕的做法,因为您可能将其部署到生产中......
2 Launch this command (adapt it to your needs).
2启动此命令(根据您的需要进行调整)。
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 .
The trick is to use the combination of those 2 parameters:
诀窍是使用这两个参数的组合:
-
--email=
(you can put whichever email address you want, I usefoobar@nowhere.com
) --passin
--email =(你可以输入你想要的任何电子邮件地址,我使用foobar@nowhere.com)
Specifying --email=
will suppress the "enter credentials" prompt, and --passin
will allow to read the password from stdin
(that's where the echo 'XX' |
comes into play!)
指定--email =将禁止“输入凭据”提示, - passin将允许从stdin读取密码(这是echo'XX'|发挥作用的地方!)
Enjoy!
P.S.: Don't forget to vote so that Google can provide an easier to use way to do that: Issue 2440.
P.S。:不要忘记投票,以便谷歌可以提供一种更容易使用的方式:问题2440。
#3
3
Edit: Look at my new solution
编辑:看看我的新解决方案
This problem is still present. I have opened a ticket to ask if the authentication could be bypassed on the local dev server. Please vote for this issue so that we can have it resolved [quickly].
这个问题仍然存在。我打开了一张票,询问是否可以在本地开发服务器上绕过身份验证。请投票支持这个问题,以便我们能够[快速]解决。
I have been able to upload data to the dev server by:
我已经能够通过以下方式将数据上传到开发服务器:
- leaving the "login:admin" line in app.yaml
- adding "--email=foobar@nowhere.com" to your command
- pressing Enter when prompted for a password (nothing required)
在app.yaml中留下“login:admin”行
将“--email=foobar@nowhere.com”添加到您的命令中
提示输入密码时按Enter键(不需要)
Leaving the "login:admin" line is a good thing, as you will not upload your app on the production servers without this line, which could expose you to someone adding data to your datastore...
离开“login:admin”行是一件好事,因为如果没有这一行,你就不会在生产服务器上上传你的应用程序,这可能会让你有人向你的数据存储区添加数据......
Blockquote
#4
2
Yes, comment out the admin requirement for the remote_api:
是的,注释掉remote_api的管理员要求:
[app.yaml]
- url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py # login: admin
Then run this command:
然后运行以下命令:
$ bulkloader.py --dump --kind=DbMyKind --url=http://localhost:8080/remote_api --filename=export.csv --app_id=my_appid --auth_domain=localhost:8080
Note: verify that --auth_domain is passed, and proper port is passed for localhost.
注意:验证是否传递了--auth_domain,并为localhost传递了正确的端口。
#5
2
Use aaa@gmail.com
for username.
使用aaa@gmail.com获取用户名。
Use a
for password.
使用密码。
It works. Magically.
有用。奇妙的。
#6
1
You need create an admin credential in your local development server first.
您需要首先在本地开发服务器中创建管理凭据。
With your firefox (or chrome safari etc), open http://localhost:8178/remote_api, you will be asked to login (without password), enter an email as your login, and tick the login as administrater
box, login. This will create you a local admin credential for you, use this when bulkloading locally.
使用你的firefox(或chrome safari等),打开http:// localhost:8178 / remote_api,你将被要求登录(没有密码),输入一个电子邮件作为你的登录,并勾选登录为administrater框,登录。这将为您创建本地管理员凭据,在本地批量加载时使用此凭据。
It applies to other admin required local access.
它适用于其他管理员所需的本地访问。
Leaving (or commenting) out login:admin
is a bad practice, since you might deploy that into production, too. Take care!
离开(或评论)登录:admin是一种不好的做法,因为您也可以将其部署到生产中。保重!
#7
1
I use this commands to transfer data from local to remote server. File's extension (json) is important. Framework: django-nonrel, os: Win7.
我使用此命令将数据从本地服务器传输到远程服务器。文件的扩展名(json)很重要。框架:django-nonrel,os:Win7。
manage.py dumpdata >dump.json
manage.py remote loaddata dump.json
#8
0
Another solution is to stub out the auth function with lambda: http://www.carlosble.com/?p=603
另一种解决方案是使用lambda来保存auth函数:http://www.carlosble.com/?p = 603
#9
0
Next worked for me:
接下来为我工作:
-
removing the line
删除线
login:admin
from app.yaml
-
Updating app cofig:
正在更新app cofig:
appcfg.py update [app-id]
-
(Re)starting local server:
(重新)启动本地服务器:
appserver [app-id]
-
Upload data:
appcfg.py upload_data --config_file=album_loader.py --filename album_data.csv --kind Album --url=http://localhost:8080/remote_api ../[app-id]
Ask for mail and password type anything
要求邮件和密码输入任何内容
#1
4
I recommend you follow the advice given here, and I quote:
我建议你按照这里给出的建议,我引用:
add this to app.yaml file:
将此添加到app.yaml文件:
-- url: /loadusers script: myloader.py login: admin
Note that if you run it on local development machine, comment off the last line login:admin so that you don't need a credential to run the bulkloader.
请注意,如果您在本地开发计算机上运行它,请注释掉最后一行login:admin,这样您就不需要凭据来运行bulkloader。
(my emphasis).
#2
6
EUREKA: I found the way to use the bulkloader.py
tool without having to manually enter login credentials.
EUREKA:我找到了使用bulkloader.py工具的方法,而无需手动输入登录凭据。
Here are the 2 steps:
以下是两个步骤:
Set your app.yaml
file up. Example:
设置app.yaml文件。例:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
You should put it BEFORE your - url: .*
line in app.yaml
, otherwise you will never access the /remote_api
url.
你应该把它放在app.yaml中你的 - url:。*行之前,否则你永远不会访问/ remote_api网址。
Note that I've left the login: admin
part, as removing it is a VERY BAD practice, since you might deploy that into production...
请注意,我已经离开了login:admin部分,因为删除它是一种非常糟糕的做法,因为您可能将其部署到生产中......
2 Launch this command (adapt it to your needs).
2启动此命令(根据您的需要进行调整)。
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 .
The trick is to use the combination of those 2 parameters:
诀窍是使用这两个参数的组合:
-
--email=
(you can put whichever email address you want, I usefoobar@nowhere.com
) --passin
--email =(你可以输入你想要的任何电子邮件地址,我使用foobar@nowhere.com)
Specifying --email=
will suppress the "enter credentials" prompt, and --passin
will allow to read the password from stdin
(that's where the echo 'XX' |
comes into play!)
指定--email =将禁止“输入凭据”提示, - passin将允许从stdin读取密码(这是echo'XX'|发挥作用的地方!)
Enjoy!
P.S.: Don't forget to vote so that Google can provide an easier to use way to do that: Issue 2440.
P.S。:不要忘记投票,以便谷歌可以提供一种更容易使用的方式:问题2440。
#3
3
Edit: Look at my new solution
编辑:看看我的新解决方案
This problem is still present. I have opened a ticket to ask if the authentication could be bypassed on the local dev server. Please vote for this issue so that we can have it resolved [quickly].
这个问题仍然存在。我打开了一张票,询问是否可以在本地开发服务器上绕过身份验证。请投票支持这个问题,以便我们能够[快速]解决。
I have been able to upload data to the dev server by:
我已经能够通过以下方式将数据上传到开发服务器:
- leaving the "login:admin" line in app.yaml
- adding "--email=foobar@nowhere.com" to your command
- pressing Enter when prompted for a password (nothing required)
在app.yaml中留下“login:admin”行
将“--email=foobar@nowhere.com”添加到您的命令中
提示输入密码时按Enter键(不需要)
Leaving the "login:admin" line is a good thing, as you will not upload your app on the production servers without this line, which could expose you to someone adding data to your datastore...
离开“login:admin”行是一件好事,因为如果没有这一行,你就不会在生产服务器上上传你的应用程序,这可能会让你有人向你的数据存储区添加数据......
Blockquote
#4
2
Yes, comment out the admin requirement for the remote_api:
是的,注释掉remote_api的管理员要求:
[app.yaml]
- url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py # login: admin
Then run this command:
然后运行以下命令:
$ bulkloader.py --dump --kind=DbMyKind --url=http://localhost:8080/remote_api --filename=export.csv --app_id=my_appid --auth_domain=localhost:8080
Note: verify that --auth_domain is passed, and proper port is passed for localhost.
注意:验证是否传递了--auth_domain,并为localhost传递了正确的端口。
#5
2
Use aaa@gmail.com
for username.
使用aaa@gmail.com获取用户名。
Use a
for password.
使用密码。
It works. Magically.
有用。奇妙的。
#6
1
You need create an admin credential in your local development server first.
您需要首先在本地开发服务器中创建管理凭据。
With your firefox (or chrome safari etc), open http://localhost:8178/remote_api, you will be asked to login (without password), enter an email as your login, and tick the login as administrater
box, login. This will create you a local admin credential for you, use this when bulkloading locally.
使用你的firefox(或chrome safari等),打开http:// localhost:8178 / remote_api,你将被要求登录(没有密码),输入一个电子邮件作为你的登录,并勾选登录为administrater框,登录。这将为您创建本地管理员凭据,在本地批量加载时使用此凭据。
It applies to other admin required local access.
它适用于其他管理员所需的本地访问。
Leaving (or commenting) out login:admin
is a bad practice, since you might deploy that into production, too. Take care!
离开(或评论)登录:admin是一种不好的做法,因为您也可以将其部署到生产中。保重!
#7
1
I use this commands to transfer data from local to remote server. File's extension (json) is important. Framework: django-nonrel, os: Win7.
我使用此命令将数据从本地服务器传输到远程服务器。文件的扩展名(json)很重要。框架:django-nonrel,os:Win7。
manage.py dumpdata >dump.json
manage.py remote loaddata dump.json
#8
0
Another solution is to stub out the auth function with lambda: http://www.carlosble.com/?p=603
另一种解决方案是使用lambda来保存auth函数:http://www.carlosble.com/?p = 603
#9
0
Next worked for me:
接下来为我工作:
-
removing the line
删除线
login:admin
from app.yaml
-
Updating app cofig:
正在更新app cofig:
appcfg.py update [app-id]
-
(Re)starting local server:
(重新)启动本地服务器:
appserver [app-id]
-
Upload data:
appcfg.py upload_data --config_file=album_loader.py --filename album_data.csv --kind Album --url=http://localhost:8080/remote_api ../[app-id]
Ask for mail and password type anything
要求邮件和密码输入任何内容