所以我尝试使用python将一个文件从引导驱动器复制到外部。因此,os.rename不是一个选项(我会得到一个跨设备错误)。我决定尝试使用shuil.move,但随后抛出了一个oserror 1,声称在其os.chmod的内部调用上不允许该操作。有趣的是,它要移动到的目录具有777权限。电话如下:

if hasattr(f.file,'name'):
                    move(f.file.name,path)

全套交易如下。
[08/Sep/2014:00:49:36] HTTP Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 670
, in respond
    response.body = self.handler()
  File "/usr/local/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 2
17, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 61
, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/pi/btsync/BitTorrentSyncWeb/py/main.py", line 129, in upload
    move(f.file.name,path)
  File "/usr/lib/python2.7/shutil.py", line 301, in move
    copy2(src, real_dst)
  File "/usr/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 100, in copystat
    os.chmod(dst, mode)
OSError: [Errno 1] Operation not permitted: '/mnt/bakery/Dump/ck.gif'

权限如下所示
$ls -l /mnt/bakery/
    drwxrwxrwx 4 root root 32768 Sep  8 01:30 Dump
$ls -l /mnt/bakery/Dump |grep ck.gif
    -rwxrwxrwx 1 root root 1017711 Sep  8 00:49 ck.gif

最佳答案

只需确保你的驱动器有一个Linux可以chmod的格式。fat32不是其中之一。

关于python - OSError:[错误1]不允许进行操作shutil.move,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25716333/

10-13 02:59