Operation not supported: ‘/home/public’,TypeError: write_error() got an unexpected keyword argument ‘exc_info’.
在程序中进行文件相关操作时遇到类似下面的问题。
[E 210728 14:30:54 web:2242] 500 POST /api/file/upload (127.0.0.1) 143.92ms
[E 210728 14:30:54 web:1784] Uncaught exception POST /api/file/upload (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:8080', method='POST', uri='/api/file/upload', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/Users/frank/PycharmProjects/FileTransfer/venv/lib/python3.8/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/Users/frank/PycharmProjects/FileTransfer/src/base/web.py", line 175, in wrapped_func
await func(request, *args, **kw_args)
File "/Users/frank/PycharmProjects/FileTransfer/src/handler/file_transfer.py", line 55, in post
os.makedirs(current_path)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 223, in makedirs
mkdir(name, mode)
OSError: [Errno 45] Operation not supported: '/home/public'
[E 210728 14:30:54 web:1216] Uncaught exception in write_error
Traceback (most recent call last):
File "/Users/frank/PycharmProjects/FileTransfer/venv/lib/python3.8/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/Users/frank/PycharmProjects/FileTransfer/src/base/web.py", line 175, in wrapped_func
await func(request, *args, **kw_args)
File "/Users/frank/PycharmProjects/FileTransfer/src/handler/file_transfer.py", line 55, in post
os.makedirs(current_path)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 213, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/Users/frank/.pyenv/versions/3.8.6/lib/python3.8/os.py", line 223, in makedirs
mkdir(name, mode)
OSError: [Errno 45] Operation not supported: '/home/public'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/frank/PycharmProjects/FileTransfer/venv/lib/python3.8/site-packages/tornado/web.py", line 1214, in send_error
self.write_error(status_code, **kwargs)
TypeError: write_error() got an unexpected keyword argument 'exc_info'
解决方案:
主要由于是没有目录操作权限造成的。
可以通过下面方式指定目录:
1)指定跟程序相同的父目录
2)指定到 /tmp 目录为父目录
3)指定其他可以允许第三方操作的目录
4)创建一级父目录,并修改其权限为 777
注意:
mac 和 linux 系统相同的目录,可访问权限可能是不一样的。