[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2018-08-03 Thread desbma


desbma  added the comment:

copy2 always raises "OSError: [Errno 95] Operation not supported" here 
https://github.com/python/cpython/blob/9bb6fe52742340f6c92f0dda18599a4577a94e18/Lib/shutil.py#L258
 but I can work around that by passing copy_function=shutil.copy to copytree as 
I did above.

The problem is that there is currently no way to avoid the copystat call made 
on the directory itself.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2018-08-03 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

It's not clear where the exception originates from. Try to use copy2() instead 
of copytree().

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2018-08-03 Thread desbma


desbma  added the comment:

Note that in the examples above both copytree calls actually succeed (only 
metadata copy failed).

The user can disable file metadata copy by passing 'copy_function=shutil.copy', 
but there is no way to do the same for directories and the directory copystat 
call 
https://github.com/python/cpython/blob/9bb6fe52742340f6c92f0dda18599a4577a94e18/Lib/shutil.py#L353
 fails.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2018-08-03 Thread desbma


desbma  added the comment:

Traceback is not very useful in that case:

mkdir /tmp/a
touch /tmp/a/b 

python
Python 3.6.6 (default, Jun 27 2018, 13:11:40) 
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, shutil
>>> os.getcwd()
'/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C006%5D/sdcard1'
>>> shutil.copytree("/tmp/a", os.path.join(os.getcwd(), "test"))
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/desbma/py-venvs/main/lib/python3.6/shutil.py", line 359, in 
copytree
raise Error(errors)
shutil.Error: [('/tmp/a/b', 
'/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C006%5D/sdcard1/test/b', '[Errno 
95] Operation not supported'), ('/tmp/a', 
'/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C006%5D/sdcard1/test', '[Errno 95] 
Operation not supported')]
>>> shutil.copytree("/tmp/a", os.path.join(os.getcwd(), "test2"), 
>>> copy_function=shutil.copy)
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/desbma/py-venvs/main/lib/python3.6/shutil.py", line 359, in 
copytree
raise Error(errors)
shutil.Error: [('/tmp/a/b', 
'/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C006%5D/sdcard1/test2/b', "[Errno 
95] Operation not supported: 
'/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C006%5D/sdcard1/test2/b'"), 
('/tmp/a', '/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C006%5D/sdcard1/test2', 
'[Errno 95] Operation not supported')]

The exception is thrown from here 
https://github.com/python/cpython/blob/9bb6fe52742340f6c92f0dda18599a4577a94e18/Lib/shutil.py#L359

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2018-08-03 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

What function raises ENOTSUPP exactly (traceback would be welcome)?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2018-06-12 Thread Giampaolo Rodola'


Change by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2017-12-19 Thread desbma

desbma  added the comment:

Ping

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2017-11-18 Thread desbma

Change by desbma :


--
keywords: +patch
pull_requests: +4394
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32073] Add copy_directory_metadata parameter to shutil.copytree

2017-11-18 Thread desbma

New submission from desbma :

I am sometimes using shutil.copytree to copy a directory to a destination that 
does not support setting metadata (like MTP mounts of Android devices).

Using the copy_function parameter allows passing shutil.copy or a custom 
function to ignore file metadata, however currently shutil.copytree always 
tries to call copystat on directories, which can fail with OSError (errno set 
to ENOTSUPP).

The code assumes copystat can fail on Windows, but propagates the error on 
other OS, even though the tree copy actually succeeds.
See 
https://github.com/python/cpython/blob/9bb6fe52742340f6c92f0dda18599a4577a94e18/Lib/shutil.py#L352-L357

--
components: Library (Lib)
messages: 306494
nosy: desbma
priority: normal
severity: normal
status: open
title: Add copy_directory_metadata parameter to shutil.copytree
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com