| 187 | class _responsetimeout(TimeoutError): pass # No response during IDLE |
| 188 | |
| 189 | def __init__(self, host='', port=IMAP4_PORT, timeout=None): |
| 190 | self.debug = Debug |
| 191 | self.state = 'LOGOUT' |
| 192 | self.literal = None # A literal argument to a command |
| 193 | self.tagged_commands = {} # Tagged commands awaiting response |
| 194 | self.untagged_responses = {} # {typ: [data, ...], ...} |
| 195 | self.continuation_response = '' # Last continuation response |
| 196 | self._idle_responses = [] # Response queue for idle iteration |
| 197 | self._idle_capture = False # Whether to queue responses for idle |
| 198 | self.is_readonly = False # READ-ONLY desired state |
| 199 | self.tagnum = 0 |
| 200 | self._tls_established = False |
| 201 | self._mode_ascii() |
| 202 | self._readbuf = [] |
| 203 | |
| 204 | # Open socket to server. |
| 205 | |
| 206 | self.open(host, port, timeout) |
| 207 | |
| 208 | try: |
| 209 | self._connect() |
| 210 | except Exception: |
| 211 | try: |
| 212 | self.shutdown() |
| 213 | except OSError: |
| 214 | pass |
| 215 | raise |
| 216 | |
| 217 | def _mode_ascii(self): |
| 218 | self.utf8_enabled = False |