From e5c4a558fbcbdd5f3e30251cae252bd93af9ede2 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Tue, 3 Apr 2012 01:13:27 +0200 Subject: [PATCH 1/7] 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 --- Changelog.rst | 3 +++ offlineimap/ui/UIBase.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.rst b/Changelog.rst index f8bdfaa..53a9797 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -17,6 +17,9 @@ Changes Bug Fixes --------- +* Don't fail if no dry-run setting exists in offlineimap.conf + (introduced in 6.5.3) + OfflineIMAP v6.5.3 (2012-04-02) =============================== diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index 4bf4423..eea929d 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -49,7 +49,7 @@ class UIBase(object): def __init__(self, config, loglevel = logging.INFO): self.config = config # Is this a 'dryrun'? - self.dryrun = config.getboolean('general', 'dry-run') + self.dryrun = config.getdefaultboolean('general', 'dry-run', False) self.debuglist = [] """list of debugtypes we are supposed to log""" self.debugmessages = {} From 6c85a4518d91c2dda0f73fe529a62feb6072e899 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Sun, 5 Aug 2012 22:40:52 +0400 Subject: [PATCH 2/7] IMAPlib mixin class: pass 'readonly' exception to our callers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will allow our callers who are capable of dealing with readonly folders to properly detect this condition and act accordingly. One example is Gmail's "Chats" folder that is read-only, but contains logs of the quick chats. Tested-by: Abdó Roig-Maranges Signed-off-by: Eygene Ryabinkin --- offlineimap/imaplibutil.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py index aa165f0..4290b2b 100644 --- a/offlineimap/imaplibutil.py +++ b/offlineimap/imaplibutil.py @@ -49,6 +49,9 @@ class UsefulIMAPMixIn(object): del self.untagged_responses[:] try: result = super(UsefulIMAPMixIn, self).select(mailbox, readonly) + except self.readonly as e: + # pass self.readonly to our callers + raise except self.abort as e: # self.abort is raised when we are supposed to retry errstr = "Server '%s' closed connection, error on SELECT '%s'. Ser"\ From aa5202396c3b5fb4228654124a059ce445bea146 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 27 Mar 2013 12:42:32 +0000 Subject: [PATCH 3/7] fix typos --- offlineimap/folder/Base.py | 2 +- offlineimap/folder/IMAP.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index c132713..6d0e8ff 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -366,7 +366,7 @@ class BaseFolder(object): raise except OfflineImapError as e: if e.severity > OfflineImapError.ERROR.MESSAGE: - raise # buble severe errors up + raise # bubble severe errors up self.ui.error(e, exc_info()[2]) except Exception as e: self.ui.error(e, "Copying message %s [acc: %s]:\n %s" %\ diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 75520c2..69bac9a 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -555,7 +555,7 @@ class IMAPFolder(BaseFolder): imapobj = self.imapserver.acquireconnection() if not retry_left: raise OfflineImapError("Saving msg in folder '%s', " - "repository '%s' failed (abort). Server reponded: %s\n" + "repository '%s' failed (abort). Server responded: %s\n" "Message content was: %s" % (self, self.getrepository(), str(e), dbg_output), OfflineImapError.ERROR.MESSAGE) @@ -567,7 +567,7 @@ class IMAPFolder(BaseFolder): self.imapserver.releaseconnection(imapobj, True) imapobj = None raise OfflineImapError("Saving msg folder '%s', repo '%s'" - "failed (error). Server reponded: %s\nMessage content was: " + "failed (error). Server responded: %s\nMessage content was: " "%s" % (self, self.getrepository(), str(e), dbg_output), OfflineImapError.ERROR.MESSAGE) # Checkpoint. Let it write out stuff, etc. Eg searches for From 84857f9430d9b755a76464d89f6f4ee8730d9370 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Fri, 19 Apr 2013 19:28:17 -0300 Subject: [PATCH 4/7] README.md: Renaming file so that github renders it nicely. --- README => README.md | 148 ++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 74 deletions(-) rename README => README.md (70%) diff --git a/README b/README.md similarity index 70% rename from README rename to README.md index 8f80d7a..edafae7 100644 --- a/README +++ b/README.md @@ -1,5 +1,5 @@ -OfflineImap README -================== +OfflineImap +=========== Description ----------- @@ -24,9 +24,9 @@ it. In fact, you are encouraged to contribute to OfflineIMAP. Documentation ------------- -The documentation is included (in .rst format) in the `docs` directory. -Read it directly or generate nice html docs (python-sphinx needed) and/or -the man page (python-docutils needed) while being in the `docs` dir via:: +The documentation is included (in .rst format) in the `docs` directory. +Read it directly or generate nice html docs (python-sphinx needed) and/or +the man page (python-docutils needed) while being in the `docs` dir via: 'make doc' (user docs), 'make man' (man page only) or 'make' (both) @@ -40,7 +40,7 @@ Quick Start =========== First, install OfflineIMAP. See docs/INSTALL.rst or read -http://docs.offlineimap.org/en/latest/INSTALL.html. +http://docs.offlineimap.org/en/latest/INSTALL.html. (hint: `sudo python setup.py install`) Second, set up your configuration file and run it! The distribution @@ -50,23 +50,23 @@ provides you with the bare minimum of setting up OfflineIMAP. You can simply copy this file into your home directory and name it ``.offlineimaprc``. A command such as ``cp offlineimap.conf.minimal ~/.offlineimaprc`` will do it. Or, if you prefer, you can just copy -this text to ``~/.offlineimaprc``:: +this text to ``~/.offlineimaprc``: - [general] - accounts = Test + [general] + accounts = Test - [Account Test] - localrepository = Local - remoterepository = Remote + [Account Test] + localrepository = Local + remoterepository = Remote - [Repository Local] - type = Maildir - localfolders = ~/Test + [Repository Local] + type = Maildir + localfolders = ~/Test - [Repository Remote] - type = IMAP - remotehost = examplehost - remoteuser = jgoerzen + [Repository Remote] + type = IMAP + remotehost = examplehost + remoteuser = jgoerzen Now, edit the ``~/.offlineimaprc`` file with your favorite editor. All you have @@ -79,9 +79,9 @@ up, ask you for a login password if necessary, synchronize your folders, and exit. See? You can just throw away the rest of the finely-crafted, perfectly-honed user -manual! Of course, if you want to see how you can make OfflineIMAP +manual! Of course, if you want to see how you can make OfflineIMAP FIVE TIMES FASTER FOR JUST $19.95 (err, well, $0), you have to read on our -full user documentation and peruse the sample offlineimap.conf (which +full user documentation and peruse the sample offlineimap.conf (which includes all available options) for further tweaks! @@ -111,28 +111,28 @@ This example shows you how to set up OfflineIMAP to synchronize multiple accounts with the mutt mail reader. Start by creating a directory to hold your folders by running ``mkdir ~/Mail``. -Then, in your ``~/.offlineimaprc``, specify:: +Then, in your ``~/.offlineimaprc``, specify: - accounts = Personal, Work + accounts = Personal, Work Make sure that you have both an [Account Personal] and an [Account Work] section. The local repository for each account must have different localfolder path names. Also, make sure to enable [mbnames]. -In each local repository section, write something like this:: +In each local repository section, write something like this: - localfolders = ~/Mail/Personal + localfolders = ~/Mail/Personal -Finally, add these lines to your ``~/.muttrc``:: +Finally, add these lines to your ``~/.muttrc``: - source ~/path-to-mbnames-muttrc-mailboxes - folder-hook Personal set from="youremail@personal.com" - folder-hook Work set from="youremail@work.com" - set mbox_type=Maildir - set folder=$HOME/Mail - spoolfile=+Personal/INBOX + source ~/path-to-mbnames-muttrc-mailboxes + folder-hook Personal set from="youremail@personal.com" + folder-hook Work set from="youremail@work.com" + set mbox_type=Maildir + set folder=$HOME/Mail + spoolfile=+Personal/INBOX That's it! @@ -146,34 +146,34 @@ to get at their mailboxes, specifying a reference of ``~/Mail`` or ``#mh/`` depending on the configuration. The below configuration from (originally from docwhat@gerf.org) shows using a reference of Mail, a nametrans that strips the leading Mail/ off incoming folder names, and a folderfilter that limits the -folders synced to just three:: +folders synced to just three: - [Account Gerf] - localrepository = GerfLocal - remoterepository = GerfRemote + [Account Gerf] + localrepository = GerfLocal + remoterepository = GerfRemote - [Repository GerfLocal] - type = Maildir - localfolders = ~/Mail + [Repository GerfLocal] + type = Maildir + localfolders = ~/Mail - [Repository GerfRemote] - type = IMAP - remotehost = gerf.org - ssl = yes - remoteuser = docwhat - reference = Mail - # Trims off the preceeding Mail on all the folder names. - nametrans = lambda foldername: \ + [Repository GerfRemote] + type = IMAP + remotehost = gerf.org + ssl = yes + remoteuser = docwhat + reference = Mail + # Trims off the preceeding Mail on all the folder names. + nametrans = lambda foldername: \ re.sub('^Mail/', '', foldername) - # Yeah, you have to mention the Mail dir, even though it - # would seem intuitive that reference would trim it. - folderfilter = lambda foldername: foldername in [ + # Yeah, you have to mention the Mail dir, even though it + # would seem intuitive that reference would trim it. + folderfilter = lambda foldername: foldername in [ 'Mail/INBOX', 'Mail/list/zaurus-general', 'Mail/list/zaurus-dev', - ] - maxconnections = 1 - holdconnectionopen = no + ] + maxconnections = 1 + holdconnectionopen = no pythonfile Configuration File Option @@ -184,34 +184,34 @@ configuration file options that are Python expressions. This example is based on one supplied by Tommi Virtanen for this feature. -In ~/.offlineimaprc, he adds these options:: +In ~/.offlineimaprc, he adds these options: - [general] - pythonfile=~/.offlineimap.py - [Repository foo] - foldersort=mycmp + [general] + pythonfile=~/.offlineimap.py + [Repository foo] + foldersort=mycmp -Then, the ~/.offlineimap.py file will contain:: +Then, the ~/.offlineimap.py file will contain: prioritized = ['INBOX', 'personal', 'announce', 'list'] - def mycmp(x, y): - for prefix in prioritized: - xsw = x.startswith(prefix) - ysw = y.startswith(prefix) - if xsw and ysw: + def mycmp(x, y): + for prefix in prioritized: + xsw = x.startswith(prefix) + ysw = y.startswith(prefix) + if xsw and ysw: + return cmp(x, y) + elif xsw: + return -1 + elif ysw: + return +1 return cmp(x, y) - elif xsw: - return -1 - elif ysw: - return +1 - return cmp(x, y) - def test_mycmp(): - import os, os.path - folders=os.listdir(os.path.expanduser('~/data/mail/tv@hq.yok.utu.fi')) - folders.sort(mycmp) - print folders + def test_mycmp(): + import os, os.path + folders=os.listdir(os.path.expanduser('~/data/mail/tv@hq.yok.utu.fi')) + folders.sort(mycmp) + print folders This code snippet illustrates how the foldersort option can be customized with a From b212e60c490d92bc180f04caea2390d27a9f0a2a Mon Sep 17 00:00:00 2001 From: Chris Pick Date: Sun, 19 May 2013 22:07:20 -0400 Subject: [PATCH 5/7] Fix small offlineimap.conf typo Maxage comment 'therefor' -> 'therefore'. --- offlineimap.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offlineimap.conf b/offlineimap.conf index fccceab..cf5a69d 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -234,7 +234,7 @@ remoterepository = RemoteExample # Messages older than maxage days will not be synced, their flags will # not be changed, they will not be deleted etc. For offlineimap it will # be like these messages do not exist. This will perform an IMAP search -# in the case of IMAP or Gmail and therefor requires that the server +# in the case of IMAP or Gmail and therefore requires that the server # support server side searching. This will calculate the earliest day # that would be included in the search and include all messages from # that day until today. e.g. maxage = 3 to sync only the last 3 days From dde021ce52990497a08d066d92e56ea019b56cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Lidstro=CC=88m?= Date: Thu, 20 Jun 2013 11:38:45 +0200 Subject: [PATCH 6/7] Added remoteporteval --- offlineimap/repository/IMAP.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index be8c858..01e78b5 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -148,6 +148,13 @@ class IMAPRepository(BaseRepository): def getport(self): + port = None + + if self.config.has_option(self.getsection(), 'remoteporteval'): + port = self.getconf('remoteporteval') + if port != None: + return self.localeval.eval(port) + return self.getconfint('remoteport', None) def getssl(self): From 7a21cab6c56b1e5b7090883e2b8772391ba56abb Mon Sep 17 00:00:00 2001 From: Dmitrijs Ledkovs Date: Wed, 10 Jul 2013 02:17:01 +0100 Subject: [PATCH 7/7] Correct whitespace & add docs about remoteporteval. --- offlineimap.conf | 1 + offlineimap/repository/IMAP.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/offlineimap.conf b/offlineimap.conf index fccceab..7b1755e 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -292,6 +292,7 @@ type = IMAP # "getcredentials" that parses a file "filename" and returns the account # details for "hostname". # remotehosteval = getcredentials("filename", "hostname", "hostname") +# remoteporteval = getcredentials("filename", "hostname", "port") # remoteusereval = getcredentials("filename", "hostname", "user") # remotepasseval = getcredentials("filename", "hostname", "passwd") diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 01e78b5..f18090f 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -148,12 +148,12 @@ class IMAPRepository(BaseRepository): def getport(self): - port = None + port = None - if self.config.has_option(self.getsection(), 'remoteporteval'): - port = self.getconf('remoteporteval') - if port != None: - return self.localeval.eval(port) + if self.config.has_option(self.getsection(), 'remoteporteval'): + port = self.getconf('remoteporteval') + if port != None: + return self.localeval.eval(port) return self.getconfint('remoteport', None)