This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: shutil.copytree copies directories and files but fails with that same directory with '[Errno 1] Operation not permitted')
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Windson Yang, giampaolo.rodola, rbavery, tarek
Priority: normal Keywords:

Created on 2019-05-07 03:47 by rbavery, last changed 2022-04-11 14:59 by admin.

Messages (4)
msg341677 - (view) Author: Ryan Avery (rbavery) Date: 2019-05-07 03:47
I am trying to use shutil.copytree on an Azure VM that has Azure FileStorage mounted with SMB 3.0. When I run the following to copy directories from one location on my Azure File Storage to another location on my File Storage, the whole directory, subdirectory, and files are copied succesfully but then this errors on those very same files:

shutil.copytree(
    os.path.join(wflow.TRAIN, 'tile_512-4608'), 
    os.path.join(wflow.TEST, 'tile_512-4608')
)

Error: [('/mnt/point/landsat-1024-cp/train/tile_512-4608/image', '/mnt/point/landsat-1024-cp/test/tile_512-4608/image', '[Errno 1] Operation not permitted'), ('/mnt/point/landsat-1024-cp/train/tile_512-4608/mask', '/mnt/point/landsat-1024-cp/test/tile_512-4608/mask', '[Errno 1] Operation not permitted'), ('/mnt/point/landsat-1024-cp/train/tile_512-4608', '/mnt/point/landsat-1024-cp/test/tile_512-4608', '[Errno 1] Operation not permitted')]

After this error, all of the items listed above were actually copied so I'm not sure why this errors
msg341701 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-05-07 09:01
Just to make sure, the expected behavior would be the items should not be copied because of the permission and the error messages above, right?
msg341803 - (view) Author: Ryan Avery (rbavery) Date: 2019-05-07 19:20
I'm actually not sure what the expected behavior would be, because I can
use the os module to copy, rename, and remove files and folders in this
mounted File Share. Before encountering this error, I would expect shutil
to do the same. But since this error comes up it would make more sense for
shutil to not copy anything.

Here are the permissions for the mounted directory, which is "."
drwxrwxrwx 2 root root    0 May  3 17:44 .
drwxr-xr-x 4 root root 4096 May  3 17:57 ..
drwxrwxrwx 2 root root    0 Apr  8 22:07 external
drwxrwxrwx 2 root root    0 May  7 00:16 landsat-1024-cp
drwxrwxrwx 2 root root    0 Apr  8 23:02 regional_annotation_projects
drwxrwxrwx 2 root root    0 May  3 21:08 results
drwxrwxrwx 2 root root    0 May  3 03:53 western_nebraska_landsat_scenes

On Tue, May 7, 2019 at 2:01 AM Windson Yang <report@bugs.python.org> wrote:

>
> Windson Yang <wiwindson@outlook.com> added the comment:
>
> Just to make sure, the expected behavior would be the items should not be
> copied because of the permission and the error messages above, right?
>
> ----------
> nosy: +Windson Yang
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue36823>
> _______________________________________
>
msg342048 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2019-05-10 02:57
You should try to copy those offending files individually via shutil.copy2() instead copytree() in order to get the full exception.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 81004
2019-05-10 02:57:31giampaolo.rodolasetmessages: + msg342048
2019-05-07 19:20:16rbaverysetmessages: + msg341803
2019-05-07 09:01:13Windson Yangsetnosy: + Windson Yang
messages: + msg341701
2019-05-07 06:06:46SilentGhostsetnosy: + giampaolo.rodola, tarek
2019-05-07 03:47:46rbaverycreate