IMAP4 client class over a stream Instantiate with: IMAP4_stream(command) "command" - a string that can be passed to subprocess.Popen() for more documentation see the docstring of the parent class IMAP4.
| 1656 | |
| 1657 | |
| 1658 | class IMAP4_stream(IMAP4): |
| 1659 | |
| 1660 | """IMAP4 client class over a stream |
| 1661 | |
| 1662 | Instantiate with: IMAP4_stream(command) |
| 1663 | |
| 1664 | "command" - a string that can be passed to subprocess.Popen() |
| 1665 | |
| 1666 | for more documentation see the docstring of the parent class IMAP4. |
| 1667 | """ |
| 1668 | |
| 1669 | |
| 1670 | def __init__(self, command): |
| 1671 | self.command = command |
| 1672 | IMAP4.__init__(self) |
| 1673 | |
| 1674 | |
| 1675 | def open(self, host=None, port=None, timeout=None): |
| 1676 | """Setup a stream connection. |
| 1677 | This connection will be used by the routines: |
| 1678 | read, readline, send, shutdown. |
| 1679 | """ |
| 1680 | self.host = None # For compatibility with parent class |
| 1681 | self.port = None |
| 1682 | self.sock = None |
| 1683 | self._file = None |
| 1684 | self.process = subprocess.Popen(self.command, |
| 1685 | bufsize=DEFAULT_BUFFER_SIZE, |
| 1686 | stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
| 1687 | shell=True, close_fds=True) |
| 1688 | self.writefile = self.process.stdin |
| 1689 | self.readfile = self.process.stdout |
| 1690 | |
| 1691 | def read(self, size): |
| 1692 | """Read 'size' bytes from remote.""" |
| 1693 | return self.readfile.read(size) |
| 1694 | |
| 1695 | |
| 1696 | def readline(self): |
| 1697 | """Read line from remote.""" |
| 1698 | return self.readfile.readline() |
| 1699 | |
| 1700 | |
| 1701 | def send(self, data): |
| 1702 | """Send data to remote.""" |
| 1703 | self.writefile.write(data) |
| 1704 | self.writefile.flush() |
| 1705 | |
| 1706 | |
| 1707 | def shutdown(self): |
| 1708 | """Close I/O established in "open".""" |
| 1709 | self.readfile.close() |
| 1710 | self.writefile.close() |
| 1711 | self.process.wait() |
| 1712 | |
| 1713 | |
| 1714 |
no outgoing calls
no test coverage detected
searching dependent graphs…