Improve getmail.py script
Features that will be useful for automated email testing:
- @--list@ or @--quit@ parameter: show a list of subjects and quit without asking. Maybe @--list@ could print the subject without any extra info (right now it shows a number and 'Subject: '), that would make easier to parse.
- @--count@: show the number of mails in a given mailbox (@--mailbox@ already implemented :])
Possible bug: When asking for a particular email it says "Hey, an empty message!", even if it's not empty. Also, when I ask for a particular body mail I get lots of errors in the bitmask app terminal, they look like this:
[2015-09-25 19:17:48] INFO - L#109 : twisted.logger._stdlib:__call__ - rcv (auth): 3 STATUS "INBOX" (UIDNEXT MESSAGES UNSEEN RECENT) [2015-09-25 19:17:48] DEBUG - L#98 : leap.bitmask.services.mail.conductor:_on_mail_client_logged_in - A MUA has logged in, should react by forcing a fetch. [2015-09-25 19:17:48] INFO - L#109 : twisted.logger._stdlib:__call__ - Building protocol for connection IPv4Address(TCP, '127.0.0.1', 36700) [2015-09-25 19:17:48] INFO - L#109 : twisted.logger._stdlib:__call__ - rcv (unauth): 2 login [...] [2015-09-25 19:17:48] INFO - L#109 : twisted.logger._stdlib:__call__ - rcv (auth): 3 select "INBOX" [2015-09-25 19:17:48] DEBUG - L#98 : leap.bitmask.services.mail.conductor:_on_mail_client_logged_in - A MUA has logged in, should react by forcing a fetch. [2015-09-25 19:17:48] DEBUG - L#163 : leap.mail.imap.mailbox:addListener - adding mailbox listener: . Total: 8 [2015-09-25 19:17:48] INFO - L#109 : twisted.logger._stdlib:__call__ - rcv (select): 4 UID fetch 1:* (FLAGS) [2015-09-25 19:17:49] INFO - L#109 : twisted.logger._stdlib:__call__ - rcv (select): 5 UID fetch 6,8,13:50 (UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (From To Cc Bcc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type Reply-To Message-ID)]) Unhandled Error Traceback (most recent call last): Failure: twisted.internet.defer.FirstError: FirstError[#1, [Failure instance: Traceback: : 'NoneType' object has no attribute 'doc_id' /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/base.py:1203:mainLoop /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/base.py:798:runUntilCurrent /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py:393:callback /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py:501:_startRunCallbacks --- --- /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py:588:_runCallbacks /home/ivan/datos/Unixono/proyectos/LEAP/leap_mail/src/leap/mail/adaptors/soledad.py:905:wrap_meta_doc ]] [2015-09-25 19:17:49] CRITICAL - L#109 : twisted.logger._stdlib:__call__ - Unhandled Error Traceback (most recent call last): Failure: twisted.internet.defer.FirstError: FirstError[#1, [Failure instance: Traceback: : 'NoneType' object has no attribute 'doc_id' /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/base.py:1203:mainLoop /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/base.py:798:runUntilCurrent /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py:393:callback /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py:501:_startRunCallbacks --- --- /home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py:588:_runCallbacks /home/ivan/datos/Unixono/proyectos/LEAP/leap_mail/src/leap/mail/adaptors/soledad.py:905:wrap_meta_doc ]] Unhandled Error Traceback (most recent call last): File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 857, in _cbDeferred self.errback(failure.Failure(FirstError(result, index))) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 434, in errback self._startRunCallbacks(fail) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks self._runCallbacks() --- --- File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/mail/imap4.py", line 1869, in __cbFetch id, msg = results.next() exceptions.AttributeError: 'NoneType' object has no attribute 'next' [2015-09-25 19:17:49] CRITICAL - L#109 : twisted.logger._stdlib:__call__ - Unhandled Error Traceback (most recent call last): File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 857, in _cbDeferred self.errback(failure.Failure(FirstError(result, index))) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 434, in errback self._startRunCallbacks(fail) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks self._runCallbacks() --- --- File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/home/ivan/.virtualenvs/bitmask/local/lib/python2.7/site-packages/twisted/mail/imap4.py", line 1869, in __cbFetch id, msg = results.next() exceptions.AttributeError: 'NoneType' object has no attribute 'next' [2015-09-25 19:17:49] INFO - L#109 : twisted.logger._stdlib:__call__ - rcv (select): 6 IDLE [2015-09-25 19:18:15] DEBUG - L#178 : leap.mail.incoming.service:fetch - fetching mail for: 982ddfe2e6f79a2e43d06b09d3f09d50 iv.6@dev.bitmask.net [2015-09-25 19:18:15] INFO - L#109 : twisted.logger._stdlib:__call__ - FETCH: syncing soledad... [2015-09-25 19:18:16] DEBUG - L#85 : leap.soledad.client.sync:sync - Soledad target sync info:
(from redmine: created on 2015-09-25, relates #7495 (closed))