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)
| 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. |