folders with gmail

Jethro Tull heavytull at hotmail.com
Sun Aug 21 22:26:02 BST 2016


version 6.7.0 "next" branch

# offlineimap.conf
    [general]
    accounts = mygmail
    ui = ttyui
    
    [mbnames]
    enabled = no
    filename = ~/.email/muttrc.mailboxes
    header = ""
    peritem = 
    sep = "/"
    footer = "\n"
    
    [Account mygmail]
    localrepository = mygmaillocal
    remoterepository = mygmailremote
    
    [Repository mygmaillocal]
    type = Maildir
    localfolders = /tmp/email_test/mygmail
    # nametrans... 
    nametrans = lambda folder: "[Gmail]/" + folder
    nametrans = lambda folder: re.sub("sent", "Sent Mail", folder)
    
    [Repository mygmailremote]
    type = IMAP
    remotehost = imap.gmail.com
    sync_deletes = no
    ssl = yes
    sslcacertfile = /etc/ssl/certs/ca-certificates.crt
    remoteport = 993
    remoteuser = heavytull
    #folderfilter = lambda folder: folder in ["[Gmail]/Sent Mail"] #  This does
                                                   #+ not work, I don't know why

    folderfilter = lambda folder: folder.startswith("[Gmail]/Sent Mail")
    nametrans = lambda folder: re.sub("^[Gmail]/", "", folder)
    nametrans = lambda folder: re.sub("Sent Mail", "sent", folder)
    createfolders = False


command line and output :
$ offlineimap -c .offlineimaprc/offlineimap.conf --dry-run -d maildir
OfflineIMAP 6.7.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
Debug mode: Forcing to singlethreaded.
Now debugging for maildir: Maildir repository debugging
Now debugging for : Other offlineimap related sync messages
Account sync mygmail:
 [maildir]: MaildirRepository initialized, sep is '.'
 *** Processing account mygmail
 Establishing connection to imap.gmail.com:993
 XOAUTH2 authentication failed: AUTHENTICATE command error: BAD ['Client aborted AUTHENTICATE command
. r19mb494530433wju']. Data: NCHC2 AUTHENTICATE XOAUTH2

Enter password for account 'mygmailremote': 
 []: Filtering out 'Archive'[mygmailremote] due to folderfilter
 []: Filtering out 'Brouillons'[mygmailremote] due to folderfilter
 []: Filtering out 'Corbeille'[mygmailremote] due to folderfilter
 []: Filtering out 'Drafts'[mygmailremote] due to folderfilter
 []: Filtering out 'Envoy&AOk-s'[mygmailremote] due to folderfilter
 []: Filtering out 'INBOX'[mygmailremote] due to folderfilter
 []: Filtering out 'Receipts'[mygmailremote] due to folderfilter
 []: Filtering out 'Sent'[mygmailremote] due to folderfilter
 []: Filtering out 'Trash'[mygmailremote] due to folderfilter
 []: Filtering out 'Work'[mygmailremote] due to folderfilter
 []: Filtering out '[Gmail]/All Mail'[mygmailremote] due to folderfilter
 []: Filtering out '[Gmail]/Bin'[mygmailremote] due to folderfilter

 []: Filtering out '[Gmail]/Drafts'[mygmailremote] due to folderfilter
 []: Filtering out '[Gmail]/Important'[mygmailremote] due to folderfilter
 []: Filtering out '[Gmail]/Spam'[mygmailremote] due to folderfilter
 []: Filtering out '[Gmail]/Starred'[mygmailremote] due to folderfilter
 [maildir]: _GETFOLDERS_SCANDIR STARTING. root = /tmp/email_test/mygmail, extension = None
 [maildir]:   toppath = /tmp/email_test/mygmail
 [maildir]:   dirname = inbox
 [maildir]:   dirname = sent
 [maildir]:   This is maildir folder 'sent'.
 [maildir]:   dirname = 
 [maildir]: _GETFOLDERS_SCANDIR RETURNING ['sent']
 [DRYRUN] Creating folder [Gmail].sent[mygmaillocal]
 []: Copying folder structure from mygmailremote to mygmaillocal
 []: Not syncing filtered folder '[Gmail]/All Mail'[mygmailremote]
 []: Not syncing filtered folder '[Gmail]/Bin'[mygmailremote]
 []: Not syncing filtered folder '[Gmail]/Drafts'[mygmailremote]
 []: Not syncing filtered folder '[Gmail]/Important'[mygmailremote]
 [maildir]: _GETFOLDERS_SCANDIR STARTING. root = /tmp/email_test/mygmail, extension = None
 [maildir]:   toppath = /tmp/email_test/mygmail
 [maildir]:   dirname = inbox
 [maildir]:   dirname = sent
 [maildir]:   This is maildir folder 'sent'.
 [maildir]:   dirname = 
 [maildir]: _GETFOLDERS_SCANDIR RETURNING ['sent']
 ERROR: getfolder() asked for a nonexisting folder '[Gmail].sent'.
 ['  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 263, in syncrunner\n    se
lf.__sync()\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 343, in __sy
nc\n    localfolder = self.get_local_folder(remotefolder)\n', '  File "/usr/lib/python2.7/site-packag
es/offlineimap/accounts.py", line 292, in get_local_folder\n    replace(self.remoterepos.getsep(), se
lf.localrepos.getsep()))\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/repository/Maildir
.py", line 150, in getfolder\n    OfflineImapError.ERROR.FOLDER)\n']
 *** Finished account 'mygmail' in 0:06
 ERROR: Exceptions occurred during the run!
 ERROR: getfolder() asked for a nonexisting folder '[Gmail].sent'.
 
Traceback:
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 263, in syncrunner
    self.__sync()
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 343, in __sync
    localfolder = self.get_local_folder(remotefolder)
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 292, in get_local_folder
    replace(self.remoterepos.getsep(), self.localrepos.getsep()))
  File "/usr/lib/python2.7/site-packages/offlineimap/repository/Maildir.py", line 150, in getfolder
    OfflineImapError.ERROR.FOLDER)


Questions:
1 - why the folder separator is '.', how to change it?
2 - why the following does not work ?
    folderfilter = lambda folder: folder in ["[Gmail]/Sent Mail"]
    Offlineimap is filtering out everything with this above line instead of the
    one with the .startswith
    If I could get this working, I could define the list of selected folders to
    sync without each time preceding the folder with the root folder "[Gmail]/"
    as following :
    folderfilter = lambda folder: "[Gmail]/" + folder in ["Sent Mail", ...]




More information about the OfflineIMAP-project mailing list