Closed 7abbix closed 5 years ago
The best workaround I can come with now is to write a wrapper to offlineimap and store the requested foldername(s) in a file which is read by the postsynchook.
The best workaround I can come with now is to write a wrapper to offlineimap and store the requested foldername(s) in a file which is read by the postsynchook.
Hi, thanks for reply. Could you please explain, why this interpolation functionality doesn't work? I can see here https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf starting at line 27, that interpolation supposed to be supported. Is this some kind of exception specifically for hooks ?
As you can see in my configuration example, I have there defined the following:
[Account Alerts] foldername = TEST
This supposed to expand %(foldername) as TEST, however offlineimap fails with error "bad interpolation variable".
Also, this official documentation demonstrates exactly the case I tried to implement: http://www.offlineimap.org/doc/ConfigurationFactorization.html
Using interpolation
It’s possible to combine values from others.
[Account Example]
localrepository = LocalExample
remoterepository = RemoteExample
mailfilter = imapfilter -c
presynchook = %(mailfilter) someconfig.lua
Is this documentation outdated and this functionality doesn't work anymore or am I missing something in my configuration?
So far I have found that this configuration:
[DEFAULT]
testvar = ABCD
[general]
accounts = Alerts
[Account Alerts]
localrepository = AlertsLocal
remoterepository = AlertsRemote
postsynchook = /srv/system/test_hook.sh %(testvar)s
Works! I get the following output:
Account sync Alerts:
Calling hook: /srv/system/test_hook.sh ABCD
Hook stdout: Supplied Argument: ABCD
Hook stderr:
Hook return code: 0
*** Finished account 'Alerts' in 0:01
It is mandatory to add the trailing "s" in interpolated variable expansion. This was not clear from docs, however.
I got also working overriding variable via command like "-k" switch. Everything works fine. The issue can be closed.
Oh, sorry. I didn't get that the interpolation default variable was in your configuration file.
General informations
offlineimap -V
): v7.2.3Configuration file offlineimaprc
pythonfile (if any)
Logs, error
Steps to reproduce the error
I am running command line invocation of offlineimap to sync only concrete folder list like this:
/usr/bin/offlineimap -o -q -c "/lib/gmail/.offlineimaprc" -f "Systems/<Name>/Problems"
, where<Name>
may be different. The commands may run simultaneously to sync different folders. And then there is logical question: There is a nice cmd option "-f", which allows to specificy (override) folderfilter from config file, this is very flexible. However, there is a logical need to process with postsync hook only those folders, which were specified in "-f" cmd option, how to implement this?I tried to use "%(foldername)", "%folder" and "%(folderfilter)" and none of these worked.
Is there a way to achieve this?
What comes to mind, is that "-f", specified in cmd arguments, should override folderfilter and hence "%(folderfilter)" used in config file should reflect overridden change, "%(folderfilter)" doesn't expand at all.
But even test variable expansion "%(foldername)" doesn't work at all. No matter it is specified in [DEFFAULT] section or in the section, where it is used.
I've found lots of offlineimaprc configuration examples on the internet, that show things like:
postsynchook = /srv/system/check_alerts.sh "%(foldername)"
but even variable from config file doesn't work.Anything I'm missing to enable variable usage?