Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] offlineimap before-poll.rb undefined method 'usual_sources'
@ 2009-11-13 15:53 Micah Anderson
  2009-11-14  0:12 ` Gaute Hope
  0 siblings, 1 reply; 2+ messages in thread
From: Micah Anderson @ 2009-11-13 15:53 UTC (permalink / raw)
  To: sup-talk


The before-poll.rb wiki example[0] seems to be what I am interested in,
however it doesn't work and provides a traceback. It reads as follows:

def offlineimap(*folders)
  cmd = "offlineimap -q -u Noninteractive.Basic"
  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 = Index.usual_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 run."
end
@last_fetch = Time.now

When I use this hook, i get this traceback in my sup log:

[Fri Nov 13 10:51:28 -0500 2009] hook: error running hook: undefined method `usual_sources' for #<Redwood::FerretIndex:0xb7520a64>
[Fri Nov 13 10:51:28 -0500 2009] hook: /usr/lib/ruby/1.8/sup/util.rb:520:in `send'
/usr/lib/ruby/1.8/sup/util.rb:520:in `method_missing'
/home/micah/.sup/hooks/before-poll.rb:11:in `inbox_sources'
/home/micah/.sup/hooks/before-poll.rb:18:in `__run'
/usr/lib/ruby/1.8/sup/hook.rb:42:in `__run'
/usr/lib/ruby/1.8/sup/hook.rb:82:in `run'
/usr/lib/ruby/1.8/sup/util.rb:520:in `send'
/usr/lib/ruby/1.8/sup/util.rb:520:in `method_missing'
/usr/lib/ruby/1.8/sup/poll.rb:45:in `poll'
/usr/lib/ruby/1.8/sup/util.rb:520:in `send'
/usr/lib/ruby/1.8/sup/util.rb:520:in `method_missing'
/usr/bin/sup-mail:195
/usr/lib/ruby/1.8/sup.rb:76:in `reporting_thread'
/usr/lib/ruby/1.8/sup.rb:74:in `initialize'
/usr/lib/ruby/1.8/sup.rb:74:in `new'
/usr/lib/ruby/1.8/sup.rb:74:in `reporting_thread'
/usr/bin/sup-mail:195
/usr/lib/ruby/1.8/sup/modes/thread-index-mode.rb:669:in `call'
/usr/lib/ruby/1.8/sup/modes/thread-index-mode.rb:669:in `__unprotected_load_threads'
/usr/lib/ruby/1.8/sup/modes/thread-index-mode.rb:610:in `call'
/usr/lib/ruby/1.8/sup/modes/thread-index-mode.rb:610:in `load_n_threads_background'
/usr/lib/ruby/1.8/sup.rb:76:in `reporting_thread'
/usr/lib/ruby/1.8/sup.rb:74:in `initialize'
/usr/lib/ruby/1.8/sup.rb:74:in `new'
/usr/lib/ruby/1.8/sup.rb:74:in `reporting_thread'
/usr/lib/ruby/1.8/sup/modes/thread-index-mode.rb:608:in `load_n_threads_background'
/usr/lib/ruby/1.8/sup/modes/thread-index-mode.rb:679:in `__unprotected_load_threads'
(eval):12:in `load_threads'
/usr/bin/sup-mail:195

Thanks,
micah


0. http://sup.rubyforge.org/wiki/wiki.pl?Hooks

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


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

* Re: [sup-talk] offlineimap before-poll.rb undefined method 'usual_sources'
  2009-11-13 15:53 [sup-talk] offlineimap before-poll.rb undefined method 'usual_sources' Micah Anderson
@ 2009-11-14  0:12 ` Gaute Hope
  0 siblings, 0 replies; 2+ messages in thread
From: Gaute Hope @ 2009-11-14  0:12 UTC (permalink / raw)
  To: sup-talk

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

Excerpts from Micah Anderson's message of fr. nov. 13 16:53:15 +0100 2009:
> 
> The before-poll.rb wiki example[0] seems to be what I am interested in,
> however it doesn't work and provides a traceback. It reads as follows:
> 
> def offlineimap(*folders)
>   cmd = "offlineimap -q -u Noninteractive.Basic"
>   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 = Index.usual_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 run."
> end
> @last_fetch = Time.now

Im using this modified version; and I filter the folders in
offlineimaprc.


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 - 20
  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

- gaute

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2009-11-14  0:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-13 15:53 [sup-talk] offlineimap before-poll.rb undefined method 'usual_sources' Micah Anderson
2009-11-14  0:12 ` Gaute Hope

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