Micah Anderson
2009-Nov-13 15:53 UTC
[sup-talk] offlineimap before-poll.rb undefined method ''usual_sources''
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
Gaute Hope
2009-Nov-14 00:12 UTC
[sup-talk] offlineimap before-poll.rb undefined method ''usual_sources''
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.nowIm 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 -------------- 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/20091114/359a15f2/attachment.bin>