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

[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

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