1. Kamyar Inanloo
  2. hgxmpp

Commits

K.Inanloo  committed bc53015

First release.

  • Participants
  • Branches default

Comments (0)

Files changed (3)

File .hgignore

View file
+syntax: glob
+.idea
+*.pyc
+*.pyo

File hgxmpp/__init__.py

View file
+__author__ = 'K.Inanloo'
+
+import os
+import xsend
+#import win32traceutil
+
+def hook(ui, repo, **kwargs):
+    username = ui.config('jabber', 'userid')
+    password = ui.config('jabber', 'password')
+    xsend.logon(username, password)
+    project = os.path.basename(repo.root)
+    text = 'Pushed \n %s  \n node %s \n from %s' % (project ,kwargs['node'], kwargs['url'])
+    if ui.config('jabber', project):
+        recipients = ui.config('jabber', project).split(',')
+        xsend.sendMessage(text, *recipients)

File hgxmpp/xsend.py

View file
+#!/usr/bin/python
+# $Id: xsend.py,v 1.8 2006/10/06 12:30:42 normanr Exp $
+import sys,os,xmpp,time
+#import win32traceutil
+
+def logon(username, password, presence = False):
+    global cl
+    jid=xmpp.protocol.JID(username)
+    cl=xmpp.Client(jid.getDomain(),debug=[])
+    con=cl.connect()
+    if not con:
+        print 'Could not connect to jabber!'
+    auth=cl.auth(jid.getNode(),password,resource=jid.getResource())
+    if not auth:
+        print 'Could not authenticate to jabber!'
+    if presence:
+        cl.SendInitPresence(requestRoster=0)
+
+def sendMessage(message, *recipients):
+    global cl
+    for person in recipients:
+        id=cl.send(xmpp.protocol.Message(person.strip(), message))