Hi,<div><br></div><div>in Python documentation for re.sub() you can find: "Changed in version 3.1: Added the optional flags argument". So the code in this patch will work only with Python 3.1+. I did not look in the code, just the stack trace you posted, but I guess we can do without using the optional "flags" in re.sub, can't we? Then the patch would be compatible with older Python versions.</div>
<div><br></div><div>Best regards,</div><div>Tomek</div><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/22 Dima Pasechnik <span dir="ltr"><<a href="mailto:dimpase+olimap@gmail.com" target="_blank">dimpase+olimap@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I am trying this patch on my gmail account<br>
(specifically, the code I use is here:<br>
<a href="https://github.com/dimpase/offlineimap" target="_blank">https://github.com/dimpase/offlineimap</a>)<br>
and get the following errors (which look like a bug being triggered):<br>
<br>
$ offlineimap<br>
OfflineIMAP 6.5.5-rc2<br>
  Licensed under the GNU GPL v2+ (v2 or any later version)<br>
Account sync main:<br>
 *** Processing account main<br>
 Establishing connection to <a href="http://imap.gmail.com:993" target="_blank">imap.gmail.com:993</a><br>
Folder [Google Mail]/All Mail [acc: main]:<br>
 Syncing [Google Mail]/All Mail: Gmail -> GmailMaildir<br>
 Collecting data from messages on [Google Mail]/All Mail<br>
 Copy message 211570 (1 of 3) gmail-remote:[Google Mail]/All Mail -> main-local<br>
 Copy message 211572 (2 of 3) gmail-remote:[Google Mail]/All Mail -> main-local<br>
 Copy message 211571 (3 of 3) gmail-remote:[Google Mail]/All Mail -> main-local<br>
Copy message from gmail-remote:[Google Mail]/All Mail:<br>
 Establishing connection to <a href="http://imap.gmail.com:993" target="_blank">imap.gmail.com:993</a><br>
 Establishing connection to <a href="http://imap.gmail.com:993" target="_blank">imap.gmail.com:993</a><br>
Folder [Google Mail]/All Mail [acc: main]:<br>
 Setting labels to message 211466 on [Google Mail].All Mail (1 of 4):<br>
 ERROR: Syncing folder [Google Mail]/All Mail [acc: main]<br>
  sub() got an unexpected keyword argument 'flags'<br>
 ERROR: ERROR in syncfolder for main folder [Google Mail]/All Mail:<br>
Traceback (most recent call last):<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/accounts.py",<br>
line 446, in syncfolder<br>
    remotefolder.syncmessagesto(localfolder, statusfolder)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/Base.py",<br>
line 642, in syncmessagesto<br>
    action(dstfolder, statusfolder)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/Gmail.py",<br>
line 328, in syncmessagesto_labels<br>
    dstfolder.savemessagelabels(uid, selflabels, ignorelabels =<br>
self.ignorelabels)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/GmailMaildir.py",<br>
line 150, in savemessagelabels<br>
    content = self.message_addheader(content, self.labelsheader, labels_str)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/Base.py",<br>
line 385, in message_addheader<br>
    leader, flags = re.MULTILINE)<br>
TypeError: sub() got an unexpected keyword argument 'flags'<br>
<br>
  sub() got an unexpected keyword argument 'flags'<br>
Account sync main:<br>
 *** Finished account 'main' in 0:45<br>
ERROR: Exceptions occurred during the run!<br>
ERROR: Syncing folder [Google Mail]/All Mail [acc: main]<br>
  sub() got an unexpected keyword argument 'flags'<br>
ERROR: ERROR in syncfolder for main folder [Google Mail]/All Mail:<br>
Traceback (most recent call last):<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/accounts.py",<br>
line 446, in syncfolder<br>
    remotefolder.syncmessagesto(localfolder, statusfolder)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/Base.py",<br>
line 642, in syncmessagesto<br>
    action(dstfolder, statusfolder)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/Gmail.py",<br>
line 328, in syncmessagesto_labels<br>
    dstfolder.savemessagelabels(uid, selflabels, ignorelabels =<br>
self.ignorelabels)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/GmailMaildir.py",<br>
line 150, in savemessagelabels<br>
    content = self.message_addheader(content, self.labelsheader, labels_str)<br>
  File "/usr/local/lib/python2.6/dist-packages/offlineimap/folder/Base.py",<br>
line 385, in message_addheader<br>
    leader, flags = re.MULTILINE)<br>
TypeError: sub() got an unexpected keyword argument 'flags'<br>
<br>
  sub() got an unexpected keyword argument 'flags'<br>
$<br>
<br>
Would be great is this is easily fixable, as I really like the extras<br>
this patch<br>
is offering.<br>
<br>
Best,<br>
Dmitrii<br>
<div class="HOEnZb"><div class="h5"><br>
On 26 October 2012 02:33, Abdó Roig-Maranges <<a href="mailto:abdo.roig@gmail.com">abdo.roig@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I've been trying to find a good way to sync gmail labels (and use them<br>
> in the email client) for some time now. My system up until now involved<br>
> syncing labels into an external file, and using a lot of glue scripts to<br>
> keep them in sync, update notmuch tags, etc. Very messy.<br>
><br>
> I've now decided to try a different approach, which seems pretty close<br>
> to the right one. I've added support in offlineimap to sync gmail<br>
> labels, and store them inside the messages, under the header<br>
> X-Keywords. This way, the labels "move with the messages" (even if I<br>
> copy the maildir to an other machine, etc etc).<br>
><br>
> There are some MUA that even recognize to some degree the X-Keywords<br>
> header or a close relative, X-Label [2]. It seems mutt supports X-Label<br>
> [3] and mu supports both [4].<br>
><br>
> I've been happily using this approach, with mu/mu4e as my MUA / indexer,<br>
> for a week now. So here I attach a couple of patches (against current<br>
> master) which do the following (see the individual commits for more<br>
> details).<br>
><br>
> bugfixes.patch :<br>
><br>
>   1. fixes a couple of easy bugs I found. It must be applied first, and<br>
>      is independent of the rest.<br>
><br>
><br>
> gmail-labels.patch:<br>
><br>
>   2. When a message goes out of gmail, adds a header X-Keywords with a<br>
>      comma separated list of labels.<br>
><br>
>   3. Updates the LocalStatus Sqlite table to include columns for labels<br>
>      and local mtimes. For non-gmail repositories these columns are<br>
>      ignored.<br>
><br>
>   4. When labels change on the gmail side, syncs them the same way as<br>
>      flags get synced (comparing with LocalStatus etc)<br>
><br>
>   5. Adds a GmailMaildir folder type, which keeps track of individual<br>
>      message modification times (the POSIX mtime), and uses it to spot<br>
>      messages which have been modified locally. Then, only for those<br>
>      modified messages (typically very few), reads the labels and syncs<br>
>      them back to gmail, the same way as flags.<br>
><br>
>   6. Adds an option to filter out certain headers when uploading<br>
>      messages to gmail. One may want to remove X-Keywords before sending<br>
>      a message back to gmail.<br>
><br>
>   7. Adds an option to ignore certain labels, like \Draft, for which<br>
>      flags serve the same purpose. Gmail internally keeps the D flag in<br>
>      sync with the \Draft label, or the F flag with the \Starred label.<br>
><br>
><br>
> Some comments:<br>
><br>
>   1. These changes (which are quite a few) should interfere minimally<br>
>      with non-gmail users. The only exception is the update on<br>
>      LocalStatus sqlite table, which I hope will cause little trouble.<br>
><br>
>   2. There are some issues with the SQLite backend. Right now, it<br>
>      commits to the database too frequently IMHO (after every message<br>
>      copy). This produces a lot of disk activity. I may look into<br>
>      it... my approach would be storing the status in memory during the<br>
>      message copying and commit to database once, at the end. Any<br>
>      thoughts? I don't think there is danger of losing data, on<br>
>      crashes. The LocalStatus will be updated correctly on the next run.<br>
><br>
>   3. The slower part is folder.Gmail.cachemessagelist, that downloads<br>
>      the uids and labels for all messages. It takes about 17 seconds<br>
>      with about 25k moderately labelled messages. I have done some<br>
>      experiments with multiple threads without improvement. My guess is<br>
>      that on the gmail side there is some sort of bandwith<br>
>      throttling. Not even compressing the connection improves matters.<br>
><br>
> Well, that's it. I send this patch hoping some developer here may take<br>
> the time to look at it. Being able to use and sync labels with the web<br>
> interface or mobile would be a very nice addition for which, as far as I<br>
> know, there is no alternative solution out there.<br>
><br>
><br>
> [1] <a href="http://comments.gmane.org/gmane.mail.imap.offlineimap.general/5916" target="_blank">http://comments.gmane.org/gmane.mail.imap.offlineimap.general/5916</a><br>
> [2] <a href="http://does-not-exist.org/mail-archives/mutt-dev/msg08249.html" target="_blank">http://does-not-exist.org/mail-archives/mutt-dev/msg08249.html</a><br>
> [3] <a href="http://blitiri.com.ar/p/other/mutt-labels/" target="_blank">http://blitiri.com.ar/p/other/mutt-labels/</a><br>
> [4] <a href="https://github.com/djcb/mu/issues/40" target="_blank">https://github.com/djcb/mu/issues/40</a><br>
><br>
> Abdó.<br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> OfflineIMAP-project mailing list<br>
> <a href="mailto:OfflineIMAP-project@lists.alioth.debian.org">OfflineIMAP-project@lists.alioth.debian.org</a><br>
> <a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project</a><br>
><br>
> OfflineIMAP homepage: <a href="http://software.complete.org/offlineimap" target="_blank">http://software.complete.org/offlineimap</a><br>
<br>
_______________________________________________<br>
OfflineIMAP-project mailing list<br>
<a href="mailto:OfflineIMAP-project@lists.alioth.debian.org">OfflineIMAP-project@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project</a><br>
<br>
OfflineIMAP homepage: <a href="http://software.complete.org/offlineimap" target="_blank">http://software.complete.org/offlineimap</a></div></div></blockquote></div><br></div>