【问题标题】:Why does google app engine tell me that umask is not implemented in python on windows?为什么谷歌应用引擎告诉我 umask 没有在 windows 上的 python 中实现?
【发布时间】:2015-12-15 01:35:40
【问题描述】:

谷歌应用引擎不支持umask吗?我可以在 Windows 上的 anaconda 中使用它,但是当我在谷歌应用引擎(在本地运行)中尝试它时,它不起作用。

这段代码:

import webapp2
import os

class MainHandler(webapp2.RequestHandler):
    def get(self):
        mask = os.umask(0o177)
        self.response.write(mask)

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

给我以下错误:

Traceback (most recent call last):

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)

File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)

File "C:\Users\Dan\Documents\Apps\test\main.py", line 22, in get
mask = os.umask(0o177)

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\stubs.py", line 40, in os_error_not_implemented
raise OSError(errno.ENOSYS, 'Function not implemented')

OSError: [Errno 40] Function not implemented

【问题讨论】:

  • 上次我检查时,它没有。 GAE 暴露了一个非常受限的环境,你不应该在那里进行文件 I/O。如果您需要这个,请在​​ GCE 上获得真正的 VPS。

标签: python google-app-engine umask


【解决方案1】:

dev_appserver(您用于“在本地运行”GAE 应用程序的程序)尽最大努力重现您在生产环境中部署和运行时(即在 appspot.com 上)在“沙盒”上遇到的限制 - - 毕竟,它是一个开发工具,旨在让您更轻松地编写和调试应用程序以部署到 appspot.com。

dev_appserver 在这个模拟方面做得并不完美,但它做得很好——特别是,禁止你的应用使用生产沙箱中不支持的标准库模块,或者特定的非在标准库模块中提供的功能仅部分受支持。 os.umask 只是后一种情况的一个例子。

【讨论】:

    猜你喜欢
    • 2015-05-06
    • 2011-09-18
    • 1970-01-01
    • 2020-05-21
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    • 2013-03-18
    • 1970-01-01
    相关资源
    最近更新 更多