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

Method retrbinary

tools/python-3.11.9-amd64/Lib/ftplib.py:421–445  ·  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 1:
438 data = conn.recv(blocksize)
439 if not data:
440 break
441 callback(data)
442 # shutdown ssl layer
443 if _SSLSocket is not None and isinstance(conn, _SSLSocket):
444 conn.unwrap()
445 return self.voidresp()
446
447 def retrlines(self, cmd, callback = None):
448 """Retrieve data in line mode. A new port is created for you.

Callers 1

testFunction · 0.95

Calls 6

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

Tested by

no test coverage detected