简体   繁体   中英

Google App Engine (python) - Connecting to local datastore via python script

I've been able to connect from a local script directly to the Google App Engine (GAE) ndb store on the server as described in this article .

But I'm trying to do the same thing to access my local dev server but am not able to. My dev API server runs at http://localhost:42020 but when I try to connect using the following command:

$ remote_api_shell.py -s http://localhost:42020

I get the following error:

Traceback (most recent call last):
  File "/home/myuser/google_appengine/remote_api_shell.py", line 127, in <module>
    run_file(__file__, globals())
  File "/home/myuser/google_appengine/remote_api_shell.py", line 123, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/home/myuser/google_appengine/google/appengine/tools/remote_api_shell.py", line 150, in <module>
    main(sys.argv)              
  File "/home/myuser/google_appengine/google/appengine/tools/remote_api_shell.py", line 146, in main
    appengine_rpc.HttpRpcServer)
  File "/home/myuser/google_appengine/google/appengine/tools/remote_api_shell.py", line 74, in remote_api_shell
    rpc_server_factory=rpc_server_factory)
  File "/home/myuser/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 874, in ConfigureRemoteApi
    app_id = GetRemoteAppIdFromServer(server, path, rtok)
  File "/home/myuser/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 569, in GetRemoteAppIdFromServer
    response = server.Send(path, payload=None, **urlargs)
  File "/home/myuser/google_appengine/google/appengine/tools/appengine_rpc.py", line 424, in Send
    f = self.opener.open(req)   
  File "/usr/lib/python2.7/urllib2.py", line 401, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 419, in _open
    '_open', req)               
  File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain
    result = func(*args)        
  File "/usr/lib/python2.7/urllib2.py", line 1211, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1181, in do_open
    raise URLError(err)         
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

Is it not possible to connect locally?

Looks like I was doing it wrong. This answer solved my problem.

In short, I had to connect to the regular web server for it to work without the leading http. This asks for my email and password and once I enter that, it works!

$ remote_api_shell.py -s localhost:8080

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM