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

Method retrbinary

Lib/ftplib.py:421–442  ·  view source on GitHub ↗

Retrieve data in binary mode. A new port is created for you. Args: cmd: A RETR command. callback: A single parameter callable to be called on each block of data read. blocksize: The maximum number of bytes to read from the

(self, cmd, callback, blocksize=8192, rest=None)

Source from the content-addressed store, hash-verified

419 return resp
420
421 def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
422 """Retrieve data in binary mode. A new port is created for you.
423
424 Args:
425 cmd: A RETR command.
426 callback: A single parameter callable to be called on each
427 block of data read.
428 blocksize: The maximum number of bytes to read from the
429 socket at one time. [default: 8192]
430 rest: Passed to transfercmd(). [default: None]
431
432 Returns:
433 The response code.
434 """
435 self.voidcmd('TYPE I')
436 with self.transfercmd(cmd, rest) as conn:
437 while data := conn.recv(blocksize):
438 callback(data)
439 # shutdown ssl layer
440 if _SSLSocket is not None and isinstance(conn, _SSLSocket):
441 conn.unwrap()
442 return self.voidresp()
443
444 def retrlines(self, cmd, callback = None):
445 """Retrieve data in line mode. A new port is created for you.

Callers 4

testFunction · 0.95
test_retrbinaryMethod · 0.80
test_retrbinary_restMethod · 0.80
retrMethod · 0.80

Calls 6

voidcmdMethod · 0.95
transfercmdMethod · 0.95
voidrespMethod · 0.95
callbackFunction · 0.70
recvMethod · 0.45
unwrapMethod · 0.45

Tested by 3

test_retrbinaryMethod · 0.64
test_retrbinary_restMethod · 0.64
retrMethod · 0.64