MCPcopy Index your code
hub / github.com/python/cpython / ftpcp

Function ftpcp

Lib/ftplib.py:879–898  ·  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

877
878
879def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
880 '''Copy file from one FTP-instance to another.'''
881 if not targetname:
882 targetname = sourcename
883 type = 'TYPE ' + type
884 source.voidcmd(type)
885 target.voidcmd(type)
886 sourcehost, sourceport = parse227(source.sendcmd('PASV'))
887 target.sendport(sourcehost, sourceport)
888 # RFC 959: the user must "listen" [...] BEFORE sending the
889 # transfer request.
890 # So: STOR before RETR, because here the target is a "user".
891 treply = target.sendcmd('STOR ' + targetname)
892 if treply[:3] not in {'125', '150'}:
893 raise error_proto # RFC 959
894 sreply = source.sendcmd('RETR ' + sourcename)
895 if sreply[:3] not in {'125', '150'}:
896 raise error_proto # RFC 959
897 source.voidresp()
898 target.voidresp()
899
900
901def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…