~sschwarzer/ftputil

1

[ftputil] FTPUTIL version of SHUTIL.COPYTREE

Details
Message ID
<2F088B80-8429-4AC9-9CAF-178690404A0C@consumertec.com>
DKIM signature
missing
Download raw message
Dear Stefan,

I hope your are well and safe.

I am working in a webapp and I found ftputil very, very useful. Congratularions. I will really appreciate if you can provide me some advice about how to use ftputil to copy an entire tree, something like shutil.copytree

Many thanks in advance.

Kind regards,


Rodrigo Olmedo

***************************************************************************************
CONSUMERTEC
Research and Development Institute in Consumer’s Benefit Perceptions
Alfredo Donoso N5-16. Tumbaco
Quito - ECUADOR
Phone: _+593 9 9949-4412
Phone/Fax: +593 2 205-2232
www.consumertec.com
***************************************************************************************
Details
Message ID
<af608579-ce49-5dd0-928b-32b21d0ff21e@sschwarzer.net>
In-Reply-To
<2F088B80-8429-4AC9-9CAF-178690404A0C@consumertec.com> (view parent)
DKIM signature
missing
Download raw message
Hi Rodrigo,

On 2020-12-07 18:04, Rodrigo Olmedo wrote:
> I hope your are well and safe.

You too. :-)

> I am working in a webapp and I found ftputil very, very useful.
> Congratularions.

Thanks for your kind words! I always like some motivation.
:-)

> I will really appreciate if you can provide me some advice
> about how to use ftputil to copy an entire tree, something
> like shutil.copytree

I see two approaches:

- There's an "unofficial" `sync` module in ftputil:
  https://ftputil.sschwarzer.net/trac/browser/ftputil/sync.py
  I never made this part of the "official" distribution
  because it's rather unfinished from my perspective (have a
  look at the code comments on the limitations that I'm
  aware of).

  That said, someone had asked a similar question as you in
  the past and they said, the `sync` module worked well
  enough for them.

- You may be able to copy the source code from Python's
  `shutil`,
  https://github.com/python/cpython/blob/3.9/Lib/shutil.py
  and adapt it for use with `FTPHost` instances.

  If I remember correctly, I used this approach quite
  successfully for `FTPHost.rmtree` and `FTPHost.walk`.
  Looking at the current source code of `shutil.copytree`,
  adapting it might be more difficult, but on the other hand
  you may not need all of the functionality. It could also
  make sense to look at `shutil.py` in earlier Python
  versions. Sometimes the earlier versions are more compact
  and easier to adapt, although they _might_ miss handling
  of edge cases. Then again, some edge cases may not occur
  in the FTP context, or can't be handled anyway due to FTP
  limitations.

Generally, it will be simpler if you don't need/want the
full functionality of `shutil.copytree` but only a subset of
the functionality.

I entered a ticket for you at
https://ftputil.sschwarzer.net/trac/ticket/144 . :-) Please
add details about what you want/need and whether or how well
the above approaches work for you.

As a spam precaution for the ticket system, you need to log
in with "ftputiluser"/"ftputil" (see
https://ftputil.sschwarzer.net/trac/wiki/IssueTracker ).
Sorry for the inconvenience. (*)

I won't make any promises when I can work on this ticket,
but let's see. Anyway, I think I should work on
https://ftputil.sschwarzer.net/trac/ticket/143 first (though
I'll probably use a different approach than in my last
ticket comment).

(*) The ticket system initially didn't require a login to
add tickets or comments. It turned out, however, that spam
bots not only added comments, but they modified ticket
properties arbitrarily, some of which aren't versioned. So I
had to restore some of the data from backups. :-/

Stefan
Reply to thread Export thread (mbox)