Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* updated before-poll hook for offlineimap
@ 2009-09-09  8:49 Gaute Hope
  2009-09-09  8:49 ` [sup-talk] " Gaute Hope
  2009-09-09 17:37 ` Gaute Hope
  0 siblings, 2 replies; 5+ messages in thread
From: Gaute Hope @ 2009-09-09  8:49 UTC (permalink / raw)
  To: Sup Talk

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [sup-talk] updated before-poll hook for offlineimap
  2009-09-09  8:49 updated before-poll hook for offlineimap Gaute Hope
@ 2009-09-09  8:49 ` Gaute Hope
  2009-09-09 17:37 ` Gaute Hope
  1 sibling, 0 replies; 5+ messages in thread
From: Gaute Hope @ 2009-09-09  8:49 UTC (permalink / raw)


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090909/1b71019d/attachment.bin>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: updated before-poll hook for offlineimap
  2009-09-09  8:49 updated before-poll hook for offlineimap Gaute Hope
  2009-09-09  8:49 ` [sup-talk] " Gaute Hope
@ 2009-09-09 17:37 ` Gaute Hope
  2009-09-09 17:37   ` [sup-talk] " Gaute Hope
  2009-09-10 14:34   ` William Morgan
  1 sibling, 2 replies; 5+ messages in thread
From: Gaute Hope @ 2009-09-09 17:37 UTC (permalink / raw)
  To: Sup Talk

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [sup-talk] updated before-poll hook for offlineimap
  2009-09-09 17:37 ` Gaute Hope
@ 2009-09-09 17:37   ` Gaute Hope
  2009-09-10 14:34   ` William Morgan
  1 sibling, 0 replies; 5+ messages in thread
From: Gaute Hope @ 2009-09-09 17:37 UTC (permalink / raw)


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://rubyforge.org/pipermail/sup-talk/attachments/20090909/ea954818/attachment.bin>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [sup-talk] updated before-poll hook for offlineimap
  2009-09-09 17:37 ` Gaute Hope
  2009-09-09 17:37   ` [sup-talk] " Gaute Hope
@ 2009-09-10 14:34   ` William Morgan
  1 sibling, 0 replies; 5+ messages in thread
From: William Morgan @ 2009-09-10 14:34 UTC (permalink / raw)


Reformatted excerpts from Gaute Hope's message of 2009-09-09:
> It seems like the before-poll.rb hooks is not run when i manually poll
> for messages; pressing P. Could this be correct?

It should be. Are you sure the before-poll hook isn't dying the first
time it's run (automatically), causing Sup to skip it the second time
(when you press P)? You can look in the log buffer.

If that's not the case, can you confirm that PollManager#poll gets
invoked in both cases?
-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-09-10 14:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-09  8:49 updated before-poll hook for offlineimap Gaute Hope
2009-09-09  8:49 ` [sup-talk] " Gaute Hope
2009-09-09 17:37 ` Gaute Hope
2009-09-09 17:37   ` [sup-talk] " Gaute Hope
2009-09-10 14:34   ` William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox