【发布时间】:2018-04-10 12:19:35
【问题描述】:
当我在 google app engine 应用程序中使用 oauth2client.file.storage.get() 时,它返回 IOError(errno.EROFS, 'Read-only file system', filename)。日志栈如下图:
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\main.py", line 291, in main
run_wsgi_app(app)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\webapp\util.py", line 101, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\webapp\util.py", line 119, in run_bare_wsgi_app
result = application(env, _start_response)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1077, in __call__
return handler.dispatch()
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\main.py", line 216, in get
response = service.searchanalytics().query(siteUrl=property_uri, body=request).execute()
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\oauth2client\_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\googleapiclient\http.py", line 836, in execute
method=str(self.method), body=self.body, headers=self.headers)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\googleapiclient\http.py", line 167, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\oauth2client\transport.py", line 186, in new_request
credentials._refresh(orig_request_method)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\oauth2client\client.py", line 761, in _refresh
self._do_refresh_request(http)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\oauth2client\client.py", line 802, in _do_refresh_request
self.store.locked_put(self)
File "c:\Users\john\AppData\Local\Google\Cloud SDK\gsc2gbq-test\oauth2client\file.py", line 85, in locked_put
f = open(self._filename, 'w')
File "C:\Users\john\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\runtime\stubs.py", line 278, in __init__
raise IOError(errno.EROFS, 'Read-only file system', filename) IOError: [Errno 30] Read-only file system: './webmaster_credentials.dat'
为了访问 Google Search Console API,我使用以下代码来验证和访问 google Search Console API。我认为这是问题的原因。
# Prepare the API service
from oauth2client.file import Storage
storage = Storage("webmaster_credentials.dat")
credentials = storage.locked_get()
http_auth = httplib2.Http()
http_auth = credentials.authorize(http_auth)
service = build('webmasters', 'v3', http=http_auth, cache_discovery=False)
我对此进行了一些研究。有聪明人指出,这是因为google app engine是只读系统。
我的问题是:如何在 Google 应用引擎中访问 google 搜索控制台 API 以及如何解决该问题:IOError(errno.EROFS, 'Read-only file system', filename)。强>
感谢您的回复或 cmets。
【问题讨论】:
标签: google-cloud-platform google-app-engine-python google-search-console