Commit Graph

117 Commits

Author SHA1 Message Date
Eygene Ryabinkin
c92c4e56a0 Add version qualifier to differentiate releases and development ones
It is always good to see which version we're talking about, so I had
added explicit marker for -devel, -release, -rcX and other states of
the OfflineIMAP.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-01 22:39:10 +04:00
Abdó Roig-Maranges
0e4afa9132 Make GmailFolder sync GMail labels
When synclabels config flag is set to "yes" for the GMail repo,
offlineimap fetches the message labels along with the messages, and
embeds them into the body under the header X-Keywords (or whatever
'labelsheader' was set to), as a comma separated list.

It also adds an extra pass to savemessageto, that performs label
synchronization on existing messages from GMail to local, the same way
it is done with flags.

We also introduce GmailMaildir repository that adds functionality to
change message labels.  It keeps track of messages modification time,
so one can quickly detect when the labels may have changed.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:36:06 +04:00
Eygene Ryabinkin
f2c858330f Always show full tracebacks at the end of the run
This greatly simplifies developer's life and will, possibly, allow
users familiar with Python to debug and fix the problems by
themselves.

We, possibly, should not give tracebacks for the problems like
"can't open connection", but this is up to the caller of this
routine not to provide traceback in this case.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-27 20:25:30 +04:00
Eygene Ryabinkin
41cb0f577f Prune trailing whitespaces from code and documentation
They are redundant in all pruned cases and sometimes even create some
problems, e.g., when one tries to jump through paragraphs in vi.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-07-21 23:00:23 +04:00
Sebastian Spaeth
a1dc76ae91 Don't output initial blurb in "quiet" mode
When logging to a file using the -l switch, we would still write an initial
banner to the file. This was never intended. Quiet should be really quiet
unless it experiences an error. Simplify the logging statement, to do nothing
if logevel is set to "WARNING" aka quiet.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-31 23:11:11 +02:00
David Logie
a614f9a735 Fix str.format() calls for Python 2.6.
Python 2.6 requires a slightly different string formatting that >2.7.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-06-02 18:25:51 +02:00
Christoph Höger
b9af72ea11 Curses UI: Reset the warn method before terminate
The warn() method tries to set the color to red. This leads to a garbled
tty after endwin() has been called. So lets simply use the UIBase
implementation.

Signed-off-by: Christoph Höger <christoph.hoeger@tu-berlin.de>
2012-04-19 17:20:49 +02:00
Sebastian Spaeth
c708e36ff7 Don't fail if no dry-run setting has been specified
Somehow we failed if no dry-run setting had been specified in the config
file. This got caught thanks to extending the test suite with a stock
configuration.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-03 01:13:27 +02:00
Eygene Ryabinkin
2f88b0296a Fix Curses interface for Python 2.6
In 2.6 all logging classes are not the new-style ones, so they
have no mro() method and, thus, we can't use super() for them.
Since CursesLogHanler is singly-inherited method, there will
be no problems in usage of the explicit superclass name.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-02 23:39:36 +02:00
Sebastian Spaeth
256a26a649 dry-run mode: Protect us from actually deleting a message in dry-run mode
Document which functions honor dry-run mode and which don't.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:05 +01:00
Sebastian Spaeth
5ef69e95c0 Prevent modifications on a folder level to occur in dry-run
Prevent savemessage(), and savemessageflags() to occur in dryrun mode in
all backends. Still need to protect against deletemessage().

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:05 +01:00
Sebastian Spaeth
b6807355b5 Implement ui.makefolder and abort repo.makefolder() in dry-run mode
IMAP, Maildir, and LocalStatus abort if in dry-run mode. IMAP and Maildir
will log that they "would have" created a new folder.

This will probably fail later on as we can not cache messagelists on
folder that don't exist, so --dry-run is not yet safe when new folders
have been created.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:03 +01:00
Sebastian Spaeth
33f55b5362 Implement dry-run on Account() level
1) Set attribute self.dryrun depending on whether we are in dry-run mode.
2) Don't actually call hooks in --dry-run (just log what you would
   invoke
3) Don't write out the mbnames file in --dry-run mode.

Repository, and Folder levels still need to be protected in dry-run mode
as of now.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 10:53:10 +01:00
Sebastian Spaeth
b7e0a51751 Add command line option --dry-run
And set the [general]dry-run=True setting if yes. It is not used yet.
Also set ui.dryrun to True so we can output what WE WOULD HAVE DONE in
dryrun mode.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 10:32:04 +01:00
Sebastian Spaeth
5c598d7e74 dict.has_key(a) --> a in dict
has_key() is gone in python3, so use a more modern syntax here.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:43 +01:00
Sebastian Spaeth
03566b2037 Replace thread.get_ident()
Replace low-level thread.get_ident() with threading.currentThread().ident.
This works both in python2.6 and python3. (thread is renamed _thread and its
direct use is not recommended)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:43 +01:00
Sebastian Spaeth
93f4a19778 python3: urlencode is in a different module
import urlencode from urllib.parse if neeeded for python3.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:42 +01:00
Sebastian Spaeth
8b6af63d83 [MachineUI] Remove unneeded "print 't'" statement
1) it's print('t') now and 2) this was a superfluous statement.
This broke python3

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:42 +01:00
Sebastian Spaeth
74fc902967 python3: import absolute package name
This import failed in python3, we need to either specify "." (relative) or
from OfflineImap.ui. (absolute). Done the latter.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:42 +01:00
Sebastian Spaeth
06a78b6112 python3: Queue -> queue
import queue (python3) if Queue is not available (python2)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:42 +01:00
Sebastian Spaeth
9df7f34d4c Remove unused locked() function
We do not use ui.locked() anymore to output an error message, the text comes
directly from the exception.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:42 +01:00
Sebastian Spaeth
7f22d89872 fix type: logging.info --> logging.INFO
We mean the (numeric) logging level here and not the info() function.
logger.isEnabledFor() takes the logging level as argument,
obviously. This was a stupid typo that failed under python3.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:40:02 +01:00
Sebastian Spaeth
36dd46abfc Fix warn() output for MachineUI
We used "self" but the paramter was called "s". Fixes a crash when we
ui.warn() (only when using the MachineUI).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-20 11:33:30 +01:00
Sebastian Spaeth
297a618441 Rename folder.getsaveduidvalidity(), folder.getuidvalidity()
Modernize names to: folder.get_saveduidvalidity(), folder.get_uidvalidity()

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-19 12:03:03 +01:00
Sebastian Spaeth
9453e1d955 Fix getuidvalidity crash (UIDVALIDITY returning None)
Rename getuidvalidity -> get_uidvalidity and cache the IMAP result.

1) Start modernizing our function names using more underscores
2) IMAPs implementation of get_uidvalidity was removing the UIDVALIDITY result
   from the imaplib2 result stack, so subsequent calls would return "None".
   As various functions can invoke this, this led to some errors that we
   avoid by caching the current UIDVALIDITY value in the Folder instance.

There are more simplifications and improvements to be made.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-19 12:02:13 +01:00
Sebastian Spaeth
48802ae4b6 TTYUI: Fix missing "time" import
commit f2a94af5 introduced the use of time.sleep in ui/TTY.py without
importing it. This caused a regression in 6.5.2, crashing OfflineIMap
when in refresh mode.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-19 02:02:55 +01:00
Sebastian Spaeth
344b2f0b7a TTYUI: Fix python 2.6 compatibility
We were using super() on a class derived from logging.Formatter() which
worked fine in python 2.7. Apparently python 2.6 uses old-style classes
for this, so the TTYUI broke and crashed OfflineImap. This was
introduced in OLI 6.5.0, I think.

Fix it by calling logging.Formatter.... directly, rather than the
elegant super() (which I happen to like a lot more than is appropriate
in the python world).

Reported by Nik Reiman as github issue 23, should fix that issue.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-18 00:39:04 +01:00
Sebastian Spaeth
f2a94af522 Don't emit regular sleeping announcements in Basic UI
They are too noisy in the Basic UI, but are still included in TTYUI.
Reported by John Wiegley.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-10 07:20:49 +01:00
Sebastian Spaeth
241e8f838b Add filter information to --info output
Prettify the folder listing in --info and add the "filtered" information
to it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-07 21:17:36 +01:00
Sebastian Spaeth
e267dcd24d Need to import OfflineImapError for --info function
An import was missing.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-07 20:33:34 +01:00
Sebastian Spaeth
968dcd5780 Make exit via 'q' key work again in Blinkenlights UI
With the new abort signal handler, we can send a signal that lets us
exit cleanly. Make use of this, rather than crashing out in ugly ways.

This affects only the Blinkenlights UI when pressing 'q'.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-07 15:02:22 +01:00
Sebastian Spaeth
415c7d7979 Fix abort_sleep missing crash in Blinkenlights UI
This is a regression introduced when renaming signals due to the
improved CTRL-C handling. Regression in 6.5.0

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-07 14:54:16 +01:00
Sebastian Spaeth
9d6a2dec37 Have log output go to STDOUT by default
THe new logging framwork spit putput to STDERR by default (as that is
pythons default), but we used to have STDERR, so make it go there again.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-07 03:04:26 +01:00
Sebastian Spaeth
946386a8e7 Restore previous MachineUI output a bit more
The logging rework led to multipline output as we stopped urlencoding
the output lines. Urrg. Fixed this, so output is urlencoded again.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-06 23:40:31 +01:00
Sebastian Spaeth
17f60f7233 Remove from __future__ import with_statements
These were needed for python <2.6 compatability, but since we depend on
python 2.6 now, these can go.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-06 23:13:55 +01:00
Sebastian Spaeth
de4f8c8605 Remove unneeded import in MachineUI
The urllib module is not needed anymore.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-06 14:06:03 +01:00
Sebastian Spaeth
d75a7a862f Fix regression of MachineUI
The recent UI overhaul led to the breakage of the machineui. This bug
fixes that.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-06 14:02:22 +01:00
Sebastian Spaeth
6f361c4d9a Don't output "Finished in x seconds" in quiet ui
The quiet UI should only output errors, and the final "Finished account
X in 2 seconds" clearly is none, so the message debug level needed to be
reduced to INFO to suppress it in the quiet ui.

Fixes https://github.com/spaetz/offlineimap/issues/6
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-01-05 13:21:08 +01:00
Sebastian Spaeth
a93c80292d Curses UI: Simplify text buffer handling
Rather than keeping a separate queue of all logged lines in memory, we
rely on the curses window scrolling functionality to scroll lines. On
resizing the terminal this means, we'll clear the screen and start
filling it afresh, but that should be acceptable.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-08 13:51:36 +01:00
Sebastian Spaeth
f8d5f1890c Make sleep abort request working again for Curses UI
1) Rework the sleep abort request to set the skipsleep configuration
   setting that the sleep() code checks.
2) Only output 15 rather than 50 debug messages on abort...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-03 14:21:25 +01:00
Sebastian Spaeth
f4a32bafd6 Pass ui.registerthread an Account() and not a name as string
This way, we can use all the account functions such as set_abort_event()
from the ui if needed.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-03 13:45:44 +01:00
Sebastian Spaeth
ef28d5dac0 More Blinkenlights UI cleanup
Rename some variables, simplify the hotkeys treatment. Refresh/exit
signals still don't work as of yet, but will come.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-03 12:25:55 +01:00
Sebastian Spaeth
70125d58e6 Curses UI: make resize behave better
Resizing a Blinkenlights terminal doesn't crash anymore, and actually
seems to be changing the size, with this patch.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-02 17:03:40 +01:00
Sebastian Spaeth
212e50eb4b Fix sleeping in the Blinkenlights UI
We were still referring to s.gettf() in sleeping(self, ...) causing each
attempt to sleep to crash. Fix this, and the CursesAccountFrame.sleeping()
method. I am sure, there is still wrong and broken but we are getting there.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-02 12:48:22 +01:00
Sebastian Spaeth
4eeb88dd8f Append, don't truncate, log file
The new logging handler was truncating the log file on each start.
Append by default.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-11-02 10:56:42 +01:00
Sebastian Spaeth
7c45e05428 Fix getExitStackTrace call
It was changed
2011-10-27 17:45:00 +02:00
Sebastian Spaeth
d992c66156 Rework the whole unused get/setExitCause machinery
It is basically unused by now. Rework to be able to make use of it
later, no functional changes.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-27 17:23:43 +02:00
Sebastian Spaeth
8195d1410f Prettify Blinkenlights.sleep()
Prettify the function.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-27 16:58:44 +02:00
Sebastian Spaeth
cbec8bb5b2 Rework UI system to make use of the logging module
Logging was flawed as the output was e.g. heavily buffered and people
complained about missing log entries. Fix this by making use of the
standard logging facilities that offlineimap offers.

This is one big ugly patch that does many things. It fixes the
Blinkenlights backend to work again with the logging facilities.

Resize windows and hotkeys are still not handled absolut correctly, this
is left for future fixing. THe rest of the backends should be working fine.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-10-27 16:23:55 +02:00
Sebastian Spaeth
0ba9634205 Fix string formatting when port is not given.
If port is None, we would try to format an empty string with %d wich
fails. Fix it by using %s.

Reported-by: Iain Dalton <iain.dalton@gmail.com>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2011-09-30 10:59:07 +02:00