MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / ftpcp

Function ftpcp

tools/python-3.11.9-amd64/Lib/ftplib.py:901–920  ·  view source on GitHub ↗

Copy file from one FTP-instance to another.

(source, sourcename, target, targetname = '', type = 'I')

Source from the content-addressed store, hash-verified

899
900
901def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
902 '''Copy file from one FTP-instance to another.'''
903 if not targetname:
904 targetname = sourcename
905 type = 'TYPE ' + type
906 source.voidcmd(type)
907 target.voidcmd(type)
908 sourcehost, sourceport = parse227(source.sendcmd('PASV'))
909 target.sendport(sourcehost, sourceport)
910 # RFC 959: the user must "listen" [...] BEFORE sending the
911 # transfer request.
912 # So: STOR before RETR, because here the target is a "user".
913 treply = target.sendcmd('STOR ' + targetname)
914 if treply[:3] not in {'125', '150'}:
915 raise error_proto # RFC 959
916 sreply = source.sendcmd('RETR ' + sourcename)
917 if sreply[:3] not in {'125', '150'}:
918 raise error_proto # RFC 959
919 source.voidresp()
920 target.voidresp()
921
922
923def test():

Callers

nothing calls this directly

Calls 5

parse227Function · 0.85
voidcmdMethod · 0.80
sendcmdMethod · 0.80
sendportMethod · 0.80
voidrespMethod · 0.80

Tested by

no test coverage detected