makedirs error: can GAE Python create new directories (folders) or not?

烈酒焚心 提交于 2020-01-05 06:55:34

问题


I have seen a number of questions relating to writing files & creating new directories using Python and GAE, but a number of them conclude (not only on SO) by saying that Python cannot write files or create new directories. Yet these commands exist and plenty of other people seem to be writing files and opening directories no problem.

I'm trying to write to .txt files and create folders and getting the following errors:

Case #1:

with open("aardvark.txt", "a") as myfile:
    myfile.write("i can't believe its not butter")

produces "IOError: [Errno 30] Read-only file system: 'aardvark.txt'". But i've checked and it's def-o not a read only file.

Case #2:

folder = r'C:\project\folder\' + str(name)
os.makedirs(folder)

produces "OSError: [Errno 38] Function not implemented: 'C:\project\folder'"

What am i missing?


回答1:


Appengine does not support any write operations to the filesystem (amongst other restrictions). The BlobStore does have a file like api, but you cannot rewrite/append to existing blob store entities. The dev server also presents these restrictions to emulate production environment.

You should probably have a read of the some of the docs about appengine. The overview doc https://developers.google.com/appengine/docs/python/overview explicitly states you can't write.




回答2:


AppEngine can now write to a local "ephemeral" disk storage when using Managed-VM which is not supported when using the sandbox method as specified on this documentation:

https://cloud.google.com/appengine/docs/managed-vms/tutorial/step3



来源:https://stackoverflow.com/questions/15699836/makedirs-error-can-gae-python-create-new-directories-folders-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!