dev_appserver.py:连接到远程数据存储区

时间:2017-12-06 10:05:33

标签: python-2.7 google-app-engine google-cloud-datastore app-engine-ndb google-app-engine-python

我在使用dev_appserver.py连接到生产数据存储区时遇到问题。

我按照https://cloud.google.com/appengine/docs/standard/python/tools/remoteapi上的教程进行操作 关于从本地脚本使用Google-Datastore,它在运行单个脚本时非常有效。

我创建了一个包含最小appengine应用程序的小型Git存储库,并在appengine_config.py脚本中添加了连接到远程数据存储区的代码。

https://github.com/fcaldas/appengine_remote_datastore

的app.yaml:

runtime: python27
api_version: 1
threadsafe: true

builtins:
- remote_api: on

handlers:
- url: /
  script: index.app

index.py:

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, World!')

app = webapp2.WSGIApplication([
         ('/', MainPage),
], debug=True)

appengine_config.py:

import os

try:
    import dev_appserver
    dev_appserver.fix_sys_path()
except ImportError:
    print "Could not import dev_appserver"
    pass


if os.environ['SERVER_SOFTWARE'].startswith('Development'):
    from google.appengine.ext.remote_api import remote_api_stub
    from google.appengine.datastore.entity_pb import Reference

    PROJECT_ID = "YOUR-PROJECT-ID"
    remote_api_stub.ConfigureRemoteApiForOAuth(
            '{}.appspot.com'.format(PROJECT_ID),
            '/_ah/remote_api/', secure=False)

    Reference.app = lambda *args: os.environ['APPLICATION_ID'].replace('dev~',
                                                                       's~')

尝试使用此方法将我的应用程序连接到数据存储区时,我收到以下错误(在dev_appserver.py终端上):

INFO     2017-12-06 09:59:03,423 sdk_update_checker.py:231] Checking for updates to the SDK.
INFO     2017-12-06 09:59:09,599 api_server.py:301] Starting API server at: http://localhost:33585
INFO     2017-12-06 09:59:09,603 dispatcher.py:251] Starting module "default" running at: http://localhost:8080
INFO     2017-12-06 09:59:09,603 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO     2017-12-06 09:59:12,314 client.py:515] Attempting refresh to obtain initial access_token
INFO     2017-12-06 09:59:12,317 client.py:755] Refreshing access_token
LOG 0 1512554362991813 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362991963 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '309', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362992791 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362992908 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '728', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362993612 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362993731 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '1147', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362994422 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362994556 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '1567', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362995171 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362995280 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '1987', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362995807 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362995915 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '2407', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362996329 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362996409 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '2827', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362997029 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362997134 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '3247', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362997744 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362997840 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '3667', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362998550 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362998642 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '4087', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362999223 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362999315 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '4507', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554362999779 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554362999878 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '4927', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363000249 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363000314 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '5347', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363000702 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363000772 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '5767', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363001131 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363001195 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '6187', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363002944 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363003074 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '6607', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363003603 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363003699 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '7027', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363004131 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363004219 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '7447', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363004622 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363004724 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '7867', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363005139 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363005224 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '8287', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363005626 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363005712 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '8707', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363006224 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363006313 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '9127', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363006804 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363006881 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '9547', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363007264 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363007339 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '9967', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363007728 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363007884 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '10387', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363009860 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363010078 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '10808', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363010776 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363011154 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '11229', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363015068 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363015981 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '11650', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363019618 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363020373 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '12071', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363021747 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363021942 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '12492', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363022552 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363022640 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '12913', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363023076 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363023159 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '13334', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363023549 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363023628 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '13755', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363024033 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363024112 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '14176', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363024507 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363024638 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '14597', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363028736 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363029130 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '15018', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363029810 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363029902 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '15439', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363030329 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363030415 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '15860', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363030977 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363031066 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '16281', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363031481 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363031573 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '16703', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363032008 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363032089 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '17126', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363032572 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363032672 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '17549', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363033032 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363033096 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '17972', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363033394 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363033453 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '18395', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363033774 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363033834 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '18818', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363034173 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363034229 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '19241', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363034556 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363034619 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '19664', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363035010 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363035092 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '20087', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363035545 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363035605 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '20510', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363035985 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363036068 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '20933', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363036447 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363036533 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '21356', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363040271 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363040941 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '21779', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
LOG 0 1512554363043081 _Authenticate configuring auth; needs_auth=False
LOG 0 1512554363043818 Sending request to http://MY-APP-ID-REMOVED.appspot.com/_ah/remote_api/ headers={'content-length': '22202', 'X-appcfg-api-version': '1', 'Content-Type': 'application/octet-stream'} body=ELIDED
RuntimeError('maximum recursion depth exceeded',)
RuntimeError('maximum recursion depth exceeded',)
Traceback (most recent call last):
  File "/home/fcaldas/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/home/fcaldas/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/home/fcaldas/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "/home/fcaldas/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 287, in __call__
    return app(environ, start_response)
  File "/home/fcaldas/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", 

...(Many lines later)...

  File "/home/fcaldas/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 240, in Send
    self._Authenticate(self.http, auth_errors[0] > 0)
  File "/home/fcaldas/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 471, in _Authenticate
    needs_auth)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1155, in debug
    self._log(DEBUG, msg, args, **kwargs)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1285, in _log
    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1259, in makeRecord
    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
  File "/usr/lib64/python2.7/logging/__init__.py", line 263, in __init__
    if (args and len(args) == 1 and isinstance(args[0], collections.Mapping)
  File "/usr/lib64/python2.7/abc.py", line 132, in __instancecheck__
    if subclass is not None and subclass in cls._abc_cache:
RuntimeError: maximum recursion depth exceeded

0 个答案:

没有答案
相关问题