bug-cvs
[Top][All Lists]
Advanced

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

Script for sending CVS notifications through Jabber


From: Michał Woźniak
Subject: Script for sending CVS notifications through Jabber
Date: Mon, 13 Feb 2006 18:03:45 +0100
User-agent: KMail/1.8.3

Hello

I have written (now that's a big word - I merely experimented and modified 
some other script) a Python script for sending CVS notifications via the 
Jabber network.

Mark D. Baushke suggested me to send it here, so that it could be added to 
contribs. If it's suitable and valuable enough - I would be more than glad.

It's available on http://rysiek.ath.cx/stuff/jabber_send.py
I also pasted the code below:
========== START CODE ========================================================
#!/usr/bin/python
#
# synopsis:
#  sending a jabber message from a specified JID (Jabber ID) with a specified
#  Password to a specified JID, text of the message is read from stdin
#  (written with cvs notifications handling in mind)
#
# dependancies:
#  you have to have Python and xmpppy (xmpppy.sourceforge.net)
#  installed on your system
#
# usage:
#
#  command line:
#   jabber_send YourJabberID YourPassword TargetJabberID
#
#  CVS:
#   to your CVSROOT/notify file add this line:
#   ALL jabber_send.py YourJID YourPasswd JID %s
#   (assuming that jabber_send.py is somewhere in your path)
#
#   or this line:
#   ALL $CVSROOT/jabber_send.py YourJID YourPasswd JID %s
#   (assuming jabber_send.py to be placed actually *in* the CVSROOT directory)
#
#  the message's text is read from stdin until EOF is reached.
#
# based on xsend.py (xmpppy project - xmpppy.sourceforge.net)
# by snakeru@users.sourceforge.net
# modified and prepared for CVS usage by Mike Wozniak <mikiwoz@yahoo.co.uk>
#
# Copyright (c) 2006, by Mike Wozniak <mikiwoz@yahoo.co.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# imports
import sys,xmpp

# args check - error messages commented out
# we don't want any error msgs while using in CVS, do we
# may enabled if using only from console
if len(sys.argv) < 4:
#    print "Syntax: xsend YourJID YourPswd JID"
#    print "the message to be sent is read from stdin until EOF found."
    sys.exit(0)

# login data
fromjid=sys.argv[1]
frompswd=sys.argv[2]
# whom are we sending this to?
tojid=sys.argv[3]

# message
text=' '.join(sys.stdin.readlines())

# let's roll - thx snakeru!
jid=xmpp.protocol.JID(fromjid)
cl=xmpp.Client(jid.getDomain(),debug=[])

cl.connect()
cl.auth(jid.getNode(),frompswd)

#cl.SendInitialPresence()
cl.send(xmpp.protocol.Message(tojid,text))

#cl.disconnect()
=================== END CODE =================================================

Cheers
Mike

                
___________________________________________________________ 
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo 
http://uk.photos.yahoo.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]