简体   繁体   English

Google App Engine(python)-通过python脚本连接到本地数据存储

[英]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 . 我因为这所描述已经能够从本地脚本直接连接到谷歌的App Engine(GAE)NDB存储在服务器上的文章

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: 我的dev API服务器运行在http://localhost:42020但是当我尝试使用以下命令进行连接时:

$ 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. 简而言之,我必须连接到常规Web服务器才能使其在没有前导http的情况下工作。 This asks for my email and password and once I enter that, it works! 这要求输入我的电子邮件和密码,一旦输入,它就可以使用!

$ remote_api_shell.py -s localhost:8080

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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