Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] before-poll.rb does not appear to be run. Where is PollManager defined?
@ 2011-06-01  3:54 Andrew Farrell
  2011-06-01 11:52 ` Ruthard Baudach
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Farrell @ 2011-06-01  3:54 UTC (permalink / raw)
  To: sup-talk


[-- Attachment #1.1: Type: text/plain, Size: 1007 bytes --]

Hello all,

I've just installed sup 0.8.1 from macports on OSX 10.6 with ruby version
1.8.7
It opens my maildir fine and I am pleased with its ability to organize mail
quickly.
I'm trying to add a before-poll.rb hook, but this appears not to be run.
At least, it is not running offlineIMAP and if I insert a divide-by-zero,
nothing explodes.
(If you care, I've attached that file.)
So, I went source-diving
into /opt/local/lib/ruby/gems/1.8/gems/sup-0.8.1/bin/sup,
but failed to find where PollManager or its method .poll is defined.
I strongly suspect it is in the gem referenced by "require 'sup' "
However, the only files so named that are in my PATH are this file itself
and a wrapper script that invokes it.
Do you know where else I might look for the definition of PollManager or
where I might look to find where it is requiring sup from?

context:
- I've never written a line of ruby.
- I'm inferring that "require 'sup' " is the equivalent of python's "from
sup import *"

thank you,
Andrew Farrell

[-- Attachment #1.2: Type: text/html, Size: 1305 bytes --]

[-- Attachment #2: before-poll.rb --]
[-- Type: application/octet-stream, Size: 759 bytes --]

# from http://sup.rubyforge.org/wiki/wiki.pl?TriggeringMailCollection
def offlineimap(*folders)
    cmd = "offlineimap -q -u Noninteractive.Basic"
    cmd << " -f #{folders * ','}" unless folders.compact.empty?
    `#{cmd} 2>&1`
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))
    File.open("~/touched", 'w') {|f| f.write("hello") } 
    say "Finished offlineimap run."
end
@last_fetch = Time.now

[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

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

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

* Re: [sup-talk] before-poll.rb does not appear to be run. Where is PollManager defined?
  2011-06-01  3:54 [sup-talk] before-poll.rb does not appear to be run. Where is PollManager defined? Andrew Farrell
@ 2011-06-01 11:52 ` Ruthard Baudach
  2011-06-01 19:18   ` Andrew Farrell
  0 siblings, 1 reply; 3+ messages in thread
From: Ruthard Baudach @ 2011-06-01 11:52 UTC (permalink / raw)
  To: sup-talk

> === Andrew Farrell schrieb am 2011-06-01 05:54: === <
> I'm trying to add a before-poll.rb hook, but this appears not to be run.
> At least, it is not running offlineIMAP and if I insert a divide-by-zero,
> nothing explodes.
To create a hook, you have to put the hook-name.rb file in the
.sup/hooks folder, and it should be executed when the hook is called.

No need to go source diving.

You've got a log-line in your before-poll.rb, so you should see it's
activity in the log buffer.

Just hit ; in inbox-mode, navigate to the line saying log-mode and hit
<Enter> to view the log buffer.

If your message shows up, the before-poll hook is executed, and does not
work. Happy debugging (I used to know no Ruby as well when I started
using sup, and it's still a foreign language to me)

> - I'm inferring that "require 'sup' " is the equivalent of python's "from
> sup import *"
Yes, it is.

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


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

* Re: [sup-talk] before-poll.rb does not appear to be run. Where is PollManager defined?
  2011-06-01 11:52 ` Ruthard Baudach
@ 2011-06-01 19:18   ` Andrew Farrell
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Farrell @ 2011-06-01 19:18 UTC (permalink / raw)
  To: sup-talk


[-- Attachment #1.1: Type: text/plain, Size: 1695 bytes --]

> Name it before-poll.rb
yes, I should have mentioned that I'd done that.

> View the log by...
Thank you! Using this, I found that the problem was that line 12 of the hook
from
http://sup.rubyforge.org/wiki/wiki.pl?TriggeringMailCollection
was using SourceManager.
12 def inbox_sources(sources = SourceManager.sources)
13     sources.find_all { |s| !s.archived? }.sort_by {|s| s.id }
14 end

I replaced SourceManager.sources with Index.usual_sources
And it works.

I've replaced the relevant code in the wiki.

-- Andrew Farrell

On Wed, Jun 1, 2011 at 4:52 AM, Ruthard Baudach <rthrd@web.de> wrote:

> > === Andrew Farrell schrieb am 2011-06-01 05:54: === <
> > I'm trying to add a before-poll.rb hook, but this appears not to be run.
> > At least, it is not running offlineIMAP and if I insert a divide-by-zero,
> > nothing explodes.
> To create a hook, you have to put the hook-name.rb file in the
> .sup/hooks folder, and it should be executed when the hook is called.
>
> No need to go source diving.
>
> You've got a log-line in your before-poll.rb, so you should see it's
> activity in the log buffer.
>
> Just hit ; in inbox-mode, navigate to the line saying log-mode and hit
> <Enter> to view the log buffer.
>
> If your message shows up, the before-poll hook is executed, and does not
> work. Happy debugging (I used to know no Ruby as well when I started
> using sup, and it's still a foreign language to me)
>
> > - I'm inferring that "require 'sup' " is the equivalent of python's "from
> > sup import *"
> Yes, it is.
>
> Ruthard
> _______________________________________________
> sup-talk mailing list
> sup-talk@rubyforge.org
> http://rubyforge.org/mailman/listinfo/sup-talk
>

[-- Attachment #1.2: Type: text/html, Size: 2955 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

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

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

end of thread, other threads:[~2011-06-01 19:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-01  3:54 [sup-talk] before-poll.rb does not appear to be run. Where is PollManager defined? Andrew Farrell
2011-06-01 11:52 ` Ruthard Baudach
2011-06-01 19:18   ` Andrew Farrell

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