views:

1764

answers:

7

Hello everyone, 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

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

Here is an extraction of the content of the models.py, I use this listcountries.csv file

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:

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 [email protected]: [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!

+3  A: 

I recommend you follow the advice given here, and I quote:

add this to app.yaml file:

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

(my emphasis).

Alex Martelli
thank you Alex! however I am current facing a new problem, I can not run any command from my command line app (windows cmd), every time I run the .py, it always show the help file, :-s I am stuck here. Thinking of changing the development to eclipse istead of notpad2 and cmd :-s
sfa
@Hoang, seems to me that issue should go in a separate question, as it's really very different from this one.
Alex Martelli
hello Alex, thank you for your suggestions! I am preparing the new question to ask again :D
sfa
Hi Alex, it seems that when I removed the login to upload data to the localhost, it still asks me to enter the email with password? Is there any other step I need to do?
sfa
try adding options --host=localhost (though I thought it would parse it correctly from the URL) -- other things to try if it still keeps breaking are [email protected] and --noisy and post all the detailed info you can see that way to help us debug (do it by editing your Q so you can format properly!-).
Alex Martelli
hi Alex, I tried all these cases but there was no change.Please note that I had succeeded to upload data to the appspot.com without any problem :-s
sfa
...and what output does --noisy give you then? Point is that --host being identically equal to 'localhost' and --email being set to anything should stop appcfg.py from asking you about email and password, so, assuming of course you have the latest version of appengine installed, you seem to be seeing an "impossible bug" if you're giving all of these flags, remove the login constraint from app.yaml, and STILL get asked. So --noisy's output will help understand where the impossible bug is coming from -- since you say you did already try it why not share that output with us?!
Alex Martelli
hi Alex, I edited the question with the output! Please take a look and give me some advices! Thank you!
sfa
Hi Alex, I think the problem is still there. I don't know how to solve it correctly, when I do a new import for a new class, the same "Authentication Failed" happened.Can you give me some suggestions
sfa
I'm all out of ideas and can't reproduce the error. I think I must have a different version of the dev sdk, 1.2.5, because those line numbers make no sense here and I can't even see some of the routines; maybe upgrade and see what happens then? Else try making a tiny app with a tiny store with a tiny module that exactly reproduces your error?
Alex Martelli
I am having the same problem. See http://gist.github.com/270341 and http://gist.github.com/270343
Ben Collins
@BenCollins, your problem is a little different from here, since you have an http 404 not found error. Checkout my app.yaml fork at http://gist.github.com/270974, which should resolve your issue.
Juvenn Woo
A: 

Next worked for me:

  • removing the line

login:admin

from app.yaml

  • Updating 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%5Fapi ../[app-id]

Ask for mail and password type anything

Conchi
A: 

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 protected]" to your command
  • pressing Enter when prompted for a password (nothing required)

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

Blockquote

Emilien
A: 

Yes, comment out the admin requirement for the 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%5Fapi --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.

turon
+2  A: 

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.

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!

Juvenn Woo
actually, removing the login:admin line is unnecessary. specifying the email address is enough. My real problem was a 404, and I discovered this afternoon that it was just an ordering issue with the URL lines in the app.yaml. the /.* url should be last, as I found out. Thanks for the followup though.
Ben Collins
A: 

EUREKA: I found the way to use the bulkloader.py tool without having to manually enter login credentials.

Here are the 2 steps:


Set your app.yaml file up. Example:

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

Note that I've left the login: admin part, as removing it is a VERY BAD practice, since you might deploy that into production...


2 Launch this command (adapt it to your needs).

echo 'XX' | python2.5 ../google_appengine/bulkloader.py --dump --kind=NAMEOFMODEL --url=http://localhost:8080/remote_api --filename=FILENAME --app_id=APPID [email protected] --passin .

The trick is to use the combination of those 2 parameters:

  • --email= (you can put whichever email address you want, I use [email protected])
  • --passin

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


Enjoy!

P.S.: Don't forget to vote so that Google can provide an easier to use way to do that: Issue 2440.

Emilien
A: 

Hi, Another solution is to stub out the auth function with lambda: http://www.carlosble.com/?p=603

Carlos Ble