From 17f60f7233b32860e3c79b30adf8d6a36daa52c9 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 6 Jan 2012 23:13:55 +0100 Subject: [PATCH 1/9] 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 --- offlineimap/folder/UIDMaps.py | 4 +--- offlineimap/imapserver.py | 1 - offlineimap/ui/Curses.py | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/offlineimap/folder/UIDMaps.py b/offlineimap/folder/UIDMaps.py index 6b361f2..1a6283c 100644 --- a/offlineimap/folder/UIDMaps.py +++ b/offlineimap/folder/UIDMaps.py @@ -1,6 +1,5 @@ # Base folder support -# Copyright (C) 2002 John Goerzen -# +# Copyright (C) 2002-2012 John Goerzen & contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from __future__ import with_statement # needed for python 2.5 from threading import Lock from IMAP import IMAPFolder import os.path diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 0106782..a355eaf 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -15,7 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from __future__ import with_statement # needed for python 2.5 from offlineimap import imaplibutil, imaputil, threadutil, OfflineImapError from offlineimap.ui import getglobalui from threading import Lock, BoundedSemaphore, Thread, Event, currentThread diff --git a/offlineimap/ui/Curses.py b/offlineimap/ui/Curses.py index f1626c4..9a2b97f 100644 --- a/offlineimap/ui/Curses.py +++ b/offlineimap/ui/Curses.py @@ -15,7 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from __future__ import with_statement # needed for python 2.5 from threading import RLock, currentThread, Lock, Event from thread import get_ident # python < 2.6 support from collections import deque From 946386a8e7813355b51967c13fa714e576ef2655 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 6 Jan 2012 23:40:31 +0100 Subject: [PATCH 2/9] 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 --- offlineimap/ui/Machine.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/offlineimap/ui/Machine.py b/offlineimap/ui/Machine.py index e6d1877..ab57ea2 100644 --- a/offlineimap/ui/Machine.py +++ b/offlineimap/ui/Machine.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - +from urllib import urlencode import sys import time import logging @@ -23,15 +23,24 @@ import offlineimap protocol = '7.0.0' +class MachineLogFormatter(logging.Formatter): + """urlencodes any outputted line, to avoid multi-line output""" + def format(self, record): + # urlencode the "mesg" attribute and append to regular line... + line = super(MachineLogFormatter, self).format(record) + return line + urlencode([('', record.mesg)])[1:] + class MachineUI(UIBase): def __init__(self, config, loglevel = logging.INFO): super(MachineUI, self).__init__(config, loglevel) self._log_con_handler.createLock() """lock needed to block on password input""" + # Set up the formatter that urlencodes the strings... + self._log_con_handler.setFormatter(MachineLogFormatter()) def _printData(self, command, msg): - self.logger.info("%s:%s:%s:%s" % ( - 'msg', command, currentThread().getName(), msg)) + self.logger.info("%s:%s:%s" % ( + 'msg', command, currentThread().getName()), extra={'mesg': msg}) def _msg(s, msg): s._printData('_display', msg) From 5509691dcf1dcf91b1e508edf54929e9a8255a9c Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 6 Jan 2012 23:47:26 +0100 Subject: [PATCH 3/9] Add Changelog entry about restored MachineUI Signed-off-by: Sebastian Spaeth --- Changelog.draft.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 76a0ea3..9608369 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -18,3 +18,7 @@ Changes Bug Fixes --------- + +* Fixed MachineUI to urlencode() output lines again, rather than + outputting multi-line items. It's ugly as hell, but it had been that + way for years. From 1b85e3525678e6038614e0510c0be7f7bc179f88 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 6 Jan 2012 23:50:54 +0100 Subject: [PATCH 4/9] Disable old global lock system Remove the old global locking system. We lock only the accounts that we currently sync, so you can invoke OfflineImap multiple times now as long as you sync different accounts. This system is compatible with all releases >= 6.4.0, so don't run older releases simultanous to this one. This mostly reverts commit 0d9565141765b8b23c1c723d325cf494e47cc80d, disabling the old global lock system that we had in parallel to the new one. Signed-off-by: Sebastian Spaeth --- Changelog.draft.rst | 6 ++++++ offlineimap/accounts.py | 1 - offlineimap/init.py | 16 ---------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 9608369..c19a285 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -13,6 +13,12 @@ others. New Features ------------ +* Remove the old global locking system. We lock only the accounts that + we currently sync, so you can invoke OfflineImap multiple times now as + long as you sync different accounts. This system is compatible with + all releases >= 6.4.0, so don't run older releases simultanous to this + one. + Changes ------- diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index 09c6882..4644604 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -191,7 +191,6 @@ class SyncableAccount(Account): def lock(self): """Lock the account, throwing an exception if it is locked already""" - # Take a new-style per-account lock self._lockfd = open(self._lockfilepath, 'w') try: fcntl.lockf(self._lockfd, fcntl.LOCK_EX|fcntl.LOCK_NB) diff --git a/offlineimap/init.py b/offlineimap/init.py index 4287b5e..4dc01aa 100644 --- a/offlineimap/init.py +++ b/offlineimap/init.py @@ -23,10 +23,6 @@ import signal import socket import logging from optparse import OptionParser -try: - import fcntl -except ImportError: - pass #it's OK import offlineimap from offlineimap import accounts, threadutil, syncmaster from offlineimap.error import OfflineImapError @@ -340,18 +336,6 @@ class OfflineImap: #various initializations that need to be performed: offlineimap.mbnames.init(self.config, syncaccounts) - #TODO: keep legacy lock for a few versions, then remove. - self._legacy_lock = open(self.config.getmetadatadir() + "/lock", - 'w') - try: - fcntl.lockf(self._legacy_lock, fcntl.LOCK_EX|fcntl.LOCK_NB) - except NameError: - #fcntl not available (Windows), disable file locking... :( - pass - except IOError: - raise OfflineImapError("Could not take global lock.", - OfflineImapError.ERROR.REPO) - if options.singlethreading: #singlethreaded self.sync_singlethreaded(syncaccounts) From ec63b4fe6b5570465eb4943059fe478b538cd2c1 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sat, 7 Jan 2012 01:28:20 +0100 Subject: [PATCH 5/9] replace imaplib internal _get_untagged_response with public functions We were using the internal imaplib2 _get_untagged_response() functions a few times. Replace 3 of these calls with 2 calls to the public function response() rather than fudging with internals that could change anytime. Signed-off-by: Sebastian Spaeth --- offlineimap/folder/IMAP.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 68d1216..7fde40b 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -68,9 +68,10 @@ class IMAPFolder(BaseFolder): def getuidvalidity(self): imapobj = self.imapserver.acquireconnection() try: - # Primes untagged_responses + # SELECT receives UIDVALIDITY response self.selectro(imapobj) - return long(imapobj._get_untagged_response('UIDVALIDITY', True)[0]) + typ, uidval = imapobj.response('UIDVALIDITY') + return long(uidval[0]) finally: self.imapserver.releaseconnection(imapobj) @@ -563,14 +564,15 @@ class IMAPFolder(BaseFolder): # get the new UID. Test for APPENDUID response even if the # server claims to not support it, as e.g. Gmail does :-( if use_uidplus or imapobj._get_untagged_response('APPENDUID', True): - # get the new UID from the APPENDUID response, it could look like - # OK [APPENDUID 38505 3955] APPEND completed - # with 38505 bein folder UIDvalidity and 3955 the new UID - if not imapobj._get_untagged_response('APPENDUID', True): + # get new UID from the APPENDUID response, it could look + # like OK [APPENDUID 38505 3955] APPEND completed with + # 38505 bein folder UIDvalidity and 3955 the new UID + typ, resp = imapobj.response('APPENDUID') + if resp == [None]: self.ui.warn("Server supports UIDPLUS but got no APPENDUID " - "appending a message.") + "appending a message. %s" % imapobj._get_untagged_response('APPENDUID', True)) return 0 - uid = long(imapobj._get_untagged_response('APPENDUID')[-1].split(' ')[1]) + uid = long(resp[-1].split(' ')[1]) else: # we don't support UIDPLUS From 3a1eab73830b22bc682af32d3ee2aedff3b546a0 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sat, 7 Jan 2012 01:31:24 +0100 Subject: [PATCH 6/9] Remove a stray debug output that slipped in the previous commit. Signed-off-by: Sebastian Spaeth --- offlineimap/folder/IMAP.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 7fde40b..93f0c56 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -570,7 +570,7 @@ class IMAPFolder(BaseFolder): typ, resp = imapobj.response('APPENDUID') if resp == [None]: self.ui.warn("Server supports UIDPLUS but got no APPENDUID " - "appending a message. %s" % imapobj._get_untagged_response('APPENDUID', True)) + "appending a message.") return 0 uid = long(resp[-1].split(' ')[1]) From 9d6a2dec37f05fd15369c2351a841709384e2900 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sat, 7 Jan 2012 03:04:26 +0100 Subject: [PATCH 7/9] 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 --- Changelog.draft.rst | 3 +++ offlineimap/ui/UIBase.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index c19a285..91f1f17 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -22,6 +22,9 @@ New Features Changes ------- +* Have console output go by default to STDOUT and not STDERR (regression + in 6.5.0) + Bug Fixes --------- diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index 5ef10cb..296159d 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -69,7 +69,7 @@ class UIBase(object): Sets up things and adds them to self.logger. :returns: The logging.Handler() for console output""" # create console handler with a higher log level - ch = logging.StreamHandler() + ch = logging.StreamHandler(sys.stdout) #ch.setLevel(logging.DEBUG) # create formatter and add it to the handlers self.formatter = logging.Formatter("%(message)s") From 0b85a34fc7f2189c224c7ad4ce533665409ed0d6 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sat, 7 Jan 2012 13:10:41 +0100 Subject: [PATCH 8/9] Maildir: flagmatchre --> re_flagmatch Overlooked a variable renaming when merging in a branch. Signed-off-by: Sebastian Spaeth --- Changelog.draft.rst | 2 ++ offlineimap/folder/Maildir.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 91f1f17..38a90b0 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -31,3 +31,5 @@ Bug Fixes * Fixed MachineUI to urlencode() output lines again, rather than outputting multi-line items. It's ugly as hell, but it had been that way for years. + +* Fixed Maildir regression "flagmatchre" not found. (regressed in 6.5.0) diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index 973bc92..938d47b 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -298,7 +298,7 @@ class MaildirFolder(BaseFolder): # Flags have actually changed, construct new filename # Strip off existing infostring (preserving small letter flags that # dovecot uses) - infomatch = self.flagmatchre.search(filename) + infomatch = self.re_flagmatch.search(filename) if infomatch: filename = filename[:-len(infomatch.group())] #strip off infostr = '%s2,%s' % (self.infosep, ''.join(sorted(flags))) From 45782ca3ac72119ac3af276cbfc763c72fada86f Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sat, 7 Jan 2012 13:15:44 +0100 Subject: [PATCH 9/9] Release v 6.5.1 OfflineIMAP v6.5.1 (2012-01-07) - "Quest for stability" ======================================================= * Fixed Maildir regression "flagmatchre" not found. (regressed in 6.5.0) * Have console output go by default to STDOUT and not STDERR (regression in 6.5.0) * Fixed MachineUI to urlencode() output lines again, rather than outputting multi-line items. It's ugly as hell, but it had been that way for years. * Remove the old global locking system. We lock only the accounts that we currently sync, so you can invoke OfflineImap multiple times now as long as you sync different accounts. This system is compatible with all releases >= 6.4.0, so don't run older releases simultanous to this one. --- Changelog.draft.rst | 14 -------------- Changelog.rst | 19 +++++++++++++++++++ offlineimap/__init__.py | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 38a90b0..1fb8079 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -13,23 +13,9 @@ others. New Features ------------ -* Remove the old global locking system. We lock only the accounts that - we currently sync, so you can invoke OfflineImap multiple times now as - long as you sync different accounts. This system is compatible with - all releases >= 6.4.0, so don't run older releases simultanous to this - one. - Changes ------- -* Have console output go by default to STDOUT and not STDERR (regression - in 6.5.0) - Bug Fixes --------- -* Fixed MachineUI to urlencode() output lines again, rather than - outputting multi-line items. It's ugly as hell, but it had been that - way for years. - -* Fixed Maildir regression "flagmatchre" not found. (regressed in 6.5.0) diff --git a/Changelog.rst b/Changelog.rst index 21f9d42..5f04e2e 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -11,6 +11,25 @@ ChangeLog on releases. And because I'm lazy, it will also be used as a draft for the releases announces. + +OfflineIMAP v6.5.1 (2012-01-07) - "Quest for stability" +======================================================= + +* Fixed Maildir regression "flagmatchre" not found. (regressed in 6.5.0) + +* Have console output go by default to STDOUT and not STDERR (regression + in 6.5.0) + +* Fixed MachineUI to urlencode() output lines again, rather than + outputting multi-line items. It's ugly as hell, but it had been that + way for years. + +* Remove the old global locking system. We lock only the accounts that + we currently sync, so you can invoke OfflineImap multiple times now as + long as you sync different accounts. This system is compatible with + all releases >= 6.4.0, so don't run older releases simultanous to this + one. + OfflineIMAP v6.5.0 (2012-01-06) =============================== diff --git a/offlineimap/__init__.py b/offlineimap/__init__.py index b16a9d6..93cdb33 100644 --- a/offlineimap/__init__.py +++ b/offlineimap/__init__.py @@ -1,7 +1,7 @@ __all__ = ['OfflineImap'] __productname__ = 'OfflineIMAP' -__version__ = "6.5.0" +__version__ = "6.5.1" __copyright__ = "Copyright 2002-2012 John Goerzen & contributors" __author__ = "John Goerzen" __author_email__= "john@complete.org" @@ -9,7 +9,7 @@ __description__ = "Disconnected Universal IMAP Mail Synchronization/Reader Suppo __license__ = "Licensed under the GNU GPL v2+ (v2 or any later version)" __bigcopyright__ = """%(__productname__)s %(__version__)s %(__license__)s""" % locals() -__homepage__ = "http://github.com/nicolas33/offlineimap" +__homepage__ = "http://offlineimap.org" banner = __bigcopyright__