Re: custom notifications

2011-02-17 Thread Wolfgang Hennerbichler
On Wed, Feb 16, 2011 at 08:09:44PM +0100, Felix Schumacher wrote:
> Hi Wolfgang,

Felix, 

> I have attached a python implementation of a notifyd, which we are using
> together with cyrus imapd 2.2.12.

Thank you very much! 
I will try it in the next days! 

Wolfgang 

Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/


Re: custom notifications

2011-02-16 Thread Felix Schumacher
Hi Wolfgang,
Am Dienstag, den 15.02.2011, 10:37 +0100 schrieb Wolfgang Hennerbichler:
> Hi, 
> 
> I'd like to write a custom notification system (using xmmp or something like 
> that, I don't know yet :)) for cyrus. 
> I've had a look at the notify_unix/simple_notify - file in the 
> contrib-directory. It doesn't seem to work in my installation (the script 
> doesn't log any notifications, although notifyd does for example notify 
> zephyr, which works), or maybe I don't understand the concept of 
> notifications. So I'd like to ask a couple of questions: 
> * does anybody have custom notifications up and running by reading the 
> notification-socket of cyrus?
> * does notifyd need to be running in order to make the notify-socket 
> readable, or is the notify-socket filled by the cyrus-master process? 
> * where would I find instructions on that? 
I have attached a python implementation of a notifyd, which we are using
together with cyrus imapd 2.2.12.

It has to be started as user cyrus (or whatever you are using to run
imapd with) and before you are starting cyrus imapd. 

It will try to remove an existing socket and recreate it, so it needs
enough rights to do it.

To resend the messages (events) it will need
http://code.google.com/p/stomppy/ and a stomp server. We are using
apache activemq for that.

Regards
 Felix

> 
> thanks a bunch, 
> wolfgang

#!/usr/bin/python
# -*- coding: utf8 -*-
'''notifyd fÃŒr cyrus imapd.

To use this daemon with cyrus imapd as a notifyd replacement, you have to

 * start the daemon before starting cyrus
 * install the daemon on the backends, if you are running it in a murder setup
 * set the values 'notifysocket' and 'mailnotifier' in /etc/imapd.conf
   e.g.
notifysocket: /var/lib/imap/socket/notify
mailnotifier: MAIL

 * start the daemon with the same user as imapd
'''
import logging
import Queue
import signal
import stomp
import socket
from threading import Thread
import time
from xml.sax.saxutils import escape as xml_escape

class QueueSender(Thread):
"""Sends messages from a python Queue to a stomp queue

>>> sender = QueueSender([('127.0.0.2', 61613), ('localhost', 61613)], '/topic/test')
>>> sender.start()
>>> for i in range(1, 400):
...if not sender.queue_message('this is a test %d' % i):
...print "could not queue message %d" % i
>>> sender.force_shutdown()
>>> sender.join()
"""
def __init__(self, config, destination, user=None, password=None):
"""Construktor for a QueueSender

\param config configuration for the stomp-server
 [('localhost', 61613), ('other.server.de', 61613)]

\param destination name of the queue or topic
 '/topic/test'
"""
Thread.__init__(self)
self.conn= None
self.config  = config
self.user= user
self.password= password
self.destination = destination
self.queue   = Queue.Queue(maxsize=300)

def __get_connection(self):
"""tries to get a connection to the configured stomp server. 
In case of exceptions, it will return None

returns:
configured connection, or None if an exception has occured
"""
if self.conn:
return self.conn
self.conn = stomp.Connection(self.config, user=self.user, passcode=self.password)
try:
self.conn.start()
except stomp.exception.ReconnectFailedException:
logging.warn(
"Probleme beim Verbinden mit dem Stomp Server. Probieren es spÀter noch einmal...")
self.conn = None
return
self.conn.connect(wait=True)
return self.conn

def __invalidate_connection(self):
self.conn = None

def queue_message(self, message, headers={} ,timeout=3):
"""queues a message to the internal queue and will send it to
the stomp server as soon as it can.

\param message to be queued

\param headers for the message, default empty dict

\param timeout for the internal queue, default 3 seconds

returns:
True if message could be queued internally, False else
"""
try:
self.queue.put(MessageElement(message, headers), True, timeout)
except Queue.Full:
return False
return True

def force_shutdown(self):
"""forces a shutdown of the sender"""
self.queue.put(KillElement())

def __se

Re: custom notifications

2011-02-15 Thread Jeroen van Meeuwen (Kolab Systems)
Wolfgang Hennerbichler wrote:
> On Tue, Feb 15, 2011 at 07:33:41AM -0500, Dave McMurtrie wrote:
> > > * does notifyd need to be running in order to make the notify-socket
> > > readable, or is the notify-socket filled by the cyrus-master process?
> > > * where would I find instructions on that?
> > 
> > You want to set the notify_external option in imapd.conf and point that
> > at a program (script, binary, whatever) that you write.  notifyd will
> > fork/exec your program and pass it -c, -p, -u and -m command line
> > arguments.  Your program can then to whatever custom notification you
> > want it to.
> > 
> > This was added in the 2.4.x series.  The imapd.conf option is documented
> > in the imapd.conf manpage ...
> 
> thanks! too bad I do still have 2.2 running (debian squeeze), and I was too
> lazy for now to find a good package maintainer or compile by myself. So I
> guess I'm stuck by now.
> 

I have some vanilla packaging effort for Debian ongoing on 
http://git.kolabsys.com/apt/cyrus-imapd/log/?h=cyrus-imapd-2.4, in case you're 
interested.

Though I'm dealing with a small backlog, compiled packages may be found at 
http://mirror.kolabsys.com/pub/debian/kolab-3.0/pool/development/c/cyrus-
imapd/

Kind regards,

Jeroen van Meeuwen

-- 
Senior Engineer, Kolab Systems AG

e: vanmeeu...@kolabsys.com
t: +316 42 801 403
w: http://www.kolabsys.com

pgp: 9342 BF08

Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/

Re: custom notifications

2011-02-15 Thread Simon Matter
> On Tue, 2011-02-15 at 10:37 +0100, Wolfgang Hennerbichler wrote:
>> Hi,
>> I'd like to write a custom notification system (using xmmp or
>> something like that, I don't know yet :)) for cyrus.
>
> +1, same here.
>
>> I've had a look at the notify_unix/simple_notify - file in the
>> contrib-directory. It doesn't seem to work in my installation (the
>> script doesn't log any notifications, although notifyd does for
>> example notify zephyr, which works), or maybe I don't understand the
>> concept of notifications. So I'd like to ask a couple of questions:
>
> I believe notifications have to be pushed by SIEVE.  At least that is
> what I recall from the last time I looked at it [quite some time ago].
>
>> * does anybody have custom notifications up and running by reading the
>> notification-socket of cyrus?
>
> Not me.  I've tried.  The documentation is beyond "thin".
>
>> * does notifyd need to be running in order to make the notify-socket
>> readable, or is the notify-socket filled by the cyrus-master process?
>
> The socket won't exist unless the notify server is defined.
>
>> * where would I find instructions on that?
>
> There is very little beyond the man page and the one perl script you
> found.

Despite the new feature in 2.4 (which I didn't know before) I've included
my notify_sms patch into the RPM and IIRC it has even worked when I tested
it :) It can be used to notify using any kind of script and it even comes
with a README.
Maybe I should remove it now that 2.4 seems to have builtin functionality
for it.

Simon


Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/


Re: custom notifications

2011-02-15 Thread Wolfgang Hennerbichler
On Tue, Feb 15, 2011 at 07:33:41AM -0500, Dave McMurtrie wrote:
> > * does notifyd need to be running in order to make the notify-socket 
> > readable, or is the notify-socket filled by the cyrus-master process?
> > * where would I find instructions on that?
> 
> You want to set the notify_external option in imapd.conf and point that
> at a program (script, binary, whatever) that you write.  notifyd will
> fork/exec your program and pass it -c, -p, -u and -m command line
> arguments.  Your program can then to whatever custom notification you
> want it to.
>
> This was added in the 2.4.x series.  The imapd.conf option is documented
> in the imapd.conf manpage ...

thanks! too bad I do still have 2.2 running (debian squeeze), and I was too 
lazy for now to find a good package maintainer or compile by myself. So I guess 
I'm stuck by now. 

> Let me know if you need any additional information.

Thank you for your help! 
 
> Thanks!
> 
> Dave

Wolfgang

> 
> Cyrus Home Page: http://www.cyrusimap.org/
> List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/

-- 
http://www.wogri.com

Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/


Re: custom notifications

2011-02-15 Thread Dave McMurtrie
...initially forgot to send to the list.  sorry.

On 02/15/2011 04:37 AM, Wolfgang Hennerbichler wrote:
> Hi,
>
> I'd like to write a custom notification system (using xmmp or something like 
> that, I don't know yet :)) for cyrus.
> I've had a look at the notify_unix/simple_notify - file in the 
> contrib-directory. It doesn't seem to work in my installation (the script 
> doesn't log any notifications, although notifyd does for example notify 
> zephyr, which works), or maybe I don't understand the concept of 
> notifications. So I'd like to ask a couple of questions:
> * does anybody have custom notifications up and running

Yes.

> by reading the notification-socket of cyrus?

No.

> * does notifyd need to be running in order to make the notify-socket 
> readable, or is the notify-socket filled by the cyrus-master process?
> * where would I find instructions on that?

You want to set the notify_external option in imapd.conf and point that
at a program (script, binary, whatever) that you write.  notifyd will
fork/exec your program and pass it -c, -p, -u and -m command line
arguments.  Your program can then to whatever custom notification you
want it to.

This was added in the 2.4.x series.  The imapd.conf option is documented
in the imapd.conf manpage here:

http://cyrusimap.org/docs/cyrus-imapd/2.4.6/man/imapd.conf.5.php

Let me know if you need any additional information.

Thanks!

Dave

Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/


Re: custom notifications

2011-02-15 Thread Adam Tauno Williams
On Tue, 2011-02-15 at 10:37 +0100, Wolfgang Hennerbichler wrote:
> Hi, 
> I'd like to write a custom notification system (using xmmp or
> something like that, I don't know yet :)) for cyrus. 

+1, same here.

> I've had a look at the notify_unix/simple_notify - file in the
> contrib-directory. It doesn't seem to work in my installation (the
> script doesn't log any notifications, although notifyd does for
> example notify zephyr, which works), or maybe I don't understand the
> concept of notifications. So I'd like to ask a couple of questions: 

I believe notifications have to be pushed by SIEVE.  At least that is
what I recall from the last time I looked at it [quite some time ago].

> * does anybody have custom notifications up and running by reading the
> notification-socket of cyrus?

Not me.  I've tried.  The documentation is beyond "thin".

> * does notifyd need to be running in order to make the notify-socket
> readable, or is the notify-socket filled by the cyrus-master process? 

The socket won't exist unless the notify server is defined.

> * where would I find instructions on that? 

There is very little beyond the man page and the one perl script you
found.


Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/


custom notifications

2011-02-15 Thread Wolfgang Hennerbichler
Hi, 

I'd like to write a custom notification system (using xmmp or something like 
that, I don't know yet :)) for cyrus. 
I've had a look at the notify_unix/simple_notify - file in the 
contrib-directory. It doesn't seem to work in my installation (the script 
doesn't log any notifications, although notifyd does for example notify zephyr, 
which works), or maybe I don't understand the concept of notifications. So I'd 
like to ask a couple of questions: 
* does anybody have custom notifications up and running by reading the 
notification-socket of cyrus?
* does notifyd need to be running in order to make the notify-socket readable, 
or is the notify-socket filled by the cyrus-master process? 
* where would I find instructions on that? 

thanks a bunch, 
wolfgang
-- 
http://www.wogri.com

Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/