Exemplo n.º 1
0
Arquivo: imap.py Projeto: simpkins/amt
 def clean_tmp_mailboxes(cls, account):
     with imap.login(account) as conn:
         responses = conn.list_mailboxes(MAILBOX_PREFIX, "*")
         for response in responses:
             mbox_name = response.mailbox.decode("ASCII", errors="strict")
             print('Deleting mailbox "%s"' % mbox_name)
             conn.delete_mailbox(response.mailbox)
Exemplo n.º 2
0
Arquivo: imap.py Projeto: simpkins/amt
    def _thread_main(self):
        try:
            with imap.login(self.account) as self.conn:
                self.conn.select_mailbox(self.mbox, readonly=True)

                # Add an event to let the the main thread know we have started
                # successfully.
                self.events.put(None)

                self._main_loop()
        except Exception as ex:
            self.events.put(ex)
        self.conn = None
Exemplo n.º 3
0
Arquivo: imap.py Projeto: simpkins/amt
    def test_copy(self, dest_conn, dest_mbox, examiner):
        with imap.login(self.account) as src_conn:
            with self.tmp_mbox(src_conn) as src_mbox:
                src_conn.select_mailbox(src_mbox.name)
                msg = random_message()
                src_conn.append_msg(src_mbox.name, msg)
                src_conn.copy(1, dest_mbox)

                response = examiner.expect_event(b"EXISTS", 1)
                # Fetch the message from the dest mailbox,
                # and make sure it is the same as the source message.
                # We have to at least send a noop on the dest conn
                # so that it sees an EXISTS response for the new message
                # before it can fetch it.  Use wait_for_exists() to do this.
                dest_conn.wait_for_exists(timeout=1)
                fetched_msg = dest_conn.fetch_msg(1)
                self.assert_msg_equal(fetched_msg, msg)
Exemplo n.º 4
0
Arquivo: imap.py Projeto: simpkins/amt
 def test_login(self):
     conn = imap.login(self.account)
     conn.close()
Exemplo n.º 5
0
Arquivo: imap.py Projeto: simpkins/amt
 def test_wrapper(self):
     with imap.login(self.account) as conn:
         with self.tmp_mbox(conn) as mbox:
             with self.examiner(mbox) as examiner:
                 conn.select_mailbox(mbox.name)
                 fn(self, conn, mbox.name, examiner)
Exemplo n.º 6
0
Arquivo: imap.py Projeto: simpkins/amt
 def test_wrapper(self):
     with imap.login(self.account) as conn:
         fn(self, conn)
Exemplo n.º 7
0
 def get_conn(self):
     return imap.login(self.server.get_account())