[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: updated before-poll hook for offlineimap



Greetings,

It seems like the before-poll.rb hooks is not run when i manually poll
for messages; pressing P. Could this be correct?

Running 8903cdedc81

- gaute

Excerpts from Gaute Hope's message of on. sep. 09 10:49:21 +0200 2009:
> Greetings,
> 
> Here's an updated before-poll.rb hook for offlineimap working with
> latest git. I'm suppressing some nasty python deprecation errors as
> well.
> 
> before-poll.rb:
> def offlineimap(*folders)
>   cmd = "offlineimap -u Noninteractive.Basic 2>&1"
>   cmd << " -f #{folders * ','}" unless folders.compact.empty?
>   `#{cmd}`
> end
> 
> def folder_names(sources)
>   sources.map { |s| s.uri.split('/').last }
> end
> 
> def inbox_sources(sources = SourceManager.sources)
>   sources.find_all { |s| !s.archived? }.sort_by {|s| s.id }
> end
> 
> if (@last_fetch || Time.at(0)) < Time.now - 120
>   say "Running offlineimap..."
>   # only check non-auto-archived sources on the first run
>   log offlineimap(@last_fetch ? nil : folder_names(inbox_sources))
>   say "Finished offlineimap."
> end
> @last_fetch = Time.now
> 
> Cheers, Gaute

Attachment: signature.asc
Description: PGP signature