2006-10-02 18:22:13 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# File: announce.py
|
|
|
|
# Version: 0.8
|
|
|
|
# Description: a script for announcing XEPs
|
|
|
|
# Last Modified: 2006-10-03
|
|
|
|
# Author: Peter Saint-Andre (stpeter@jabber.org)
|
|
|
|
# License: public domain
|
2007-06-18 22:11:11 -04:00
|
|
|
# HowTo: ./announce.py xepnum 'diffsurl'
|
|
|
|
# NOTE: the diffsurl MUST be in quotes!
|
2006-10-02 18:22:13 -04:00
|
|
|
|
2008-04-22 12:37:14 -04:00
|
|
|
## LICENSE ##
|
|
|
|
#
|
2009-01-05 11:28:58 -05:00
|
|
|
# Copyright (c) 1999 - 2009 XMPP Standards Foundation
|
2008-04-22 12:37:14 -04:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE.
|
|
|
|
#
|
|
|
|
## END LICENSE ##
|
|
|
|
|
2006-10-02 18:22:13 -04:00
|
|
|
# IMPORTS:
|
|
|
|
#
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
from select import select
|
|
|
|
import smtplib
|
|
|
|
import socket
|
|
|
|
from string import split,strip,join,find
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
from xml.dom.minidom import parse,parseString,Document
|
|
|
|
|
|
|
|
def getText(nodelist):
|
|
|
|
thisText = ""
|
|
|
|
for node in nodelist:
|
|
|
|
if node.nodeType == node.TEXT_NODE:
|
|
|
|
thisText = thisText + node.data
|
|
|
|
return thisText
|
|
|
|
|
|
|
|
# get the seconds in the Unix era
|
|
|
|
now = int(time.time())
|
|
|
|
|
|
|
|
# READ IN ARGS:
|
|
|
|
#
|
|
|
|
# 1. XEP number
|
2007-06-18 22:11:11 -04:00
|
|
|
# 2. URL for source control diffs
|
2006-10-02 18:22:13 -04:00
|
|
|
|
|
|
|
xepnum = sys.argv[1];
|
2007-06-18 22:11:11 -04:00
|
|
|
diffs = sys.argv[2];
|
2006-10-02 18:22:13 -04:00
|
|
|
|
|
|
|
xepfile = 'xep-' + xepnum + '.xml'
|
|
|
|
|
|
|
|
# PARSE XEP HEADERS:
|
|
|
|
#
|
|
|
|
# - title
|
|
|
|
# - abstract
|
|
|
|
# - version
|
|
|
|
# - date
|
|
|
|
# - initials
|
|
|
|
# - remark
|
|
|
|
|
|
|
|
thexep = parse(xepfile)
|
|
|
|
xepNode = (thexep.getElementsByTagName("xep")[0])
|
|
|
|
headerNode = (xepNode.getElementsByTagName("header")[0])
|
|
|
|
titleNode = (headerNode.getElementsByTagName("title")[0])
|
|
|
|
title = getText(titleNode.childNodes)
|
|
|
|
abstractNode = (headerNode.getElementsByTagName("abstract")[0])
|
|
|
|
abstract = getText(abstractNode.childNodes)
|
|
|
|
statusNode = (headerNode.getElementsByTagName("status")[0])
|
|
|
|
xepstatus = getText(statusNode.childNodes)
|
|
|
|
typeNode = (headerNode.getElementsByTagName("type")[0])
|
|
|
|
xeptype = getText(typeNode.childNodes)
|
|
|
|
revNode = (headerNode.getElementsByTagName("revision")[0])
|
|
|
|
versionNode = (revNode.getElementsByTagName("version")[0])
|
|
|
|
version = getText(versionNode.childNodes)
|
|
|
|
dateNode = (revNode.getElementsByTagName("date")[0])
|
|
|
|
date = getText(dateNode.childNodes)
|
|
|
|
initialsNode = (revNode.getElementsByTagName("initials")[0])
|
|
|
|
initials = getText(initialsNode.childNodes)
|
|
|
|
remNode = (revNode.getElementsByTagName("remark")[0])
|
|
|
|
# could be <p> or <ul>
|
|
|
|
testRemarkNode = remNode.firstChild.nodeName
|
|
|
|
# print testRemarkNode
|
|
|
|
if (testRemarkNode == "p"):
|
|
|
|
remarkNode = (remNode.getElementsByTagName("p")[0])
|
|
|
|
remark = getText(remarkNode.childNodes)
|
|
|
|
else:
|
|
|
|
remark = "[See revision history]"
|
|
|
|
|
|
|
|
# what kind of action are we taking?
|
|
|
|
xepflag = ""
|
|
|
|
if (version == "0.1"):
|
|
|
|
xepflag = "new"
|
|
|
|
elif ((version == "1.0") & (xeptype == "Standards Track")):
|
|
|
|
xepflag = "draft"
|
|
|
|
elif ((version == "1.0") & (xeptype != "Standards Track")):
|
|
|
|
xepflag = "active"
|
|
|
|
elif (version == "2.0"):
|
|
|
|
xepflag = "final"
|
|
|
|
elif (xepstatus == "Retracted"):
|
|
|
|
xepflag = "retract"
|
2007-01-17 17:54:29 -05:00
|
|
|
elif (xepstatus == "Deprecated"):
|
|
|
|
xepflag = "deprecate"
|
2006-10-02 18:22:13 -04:00
|
|
|
elif (xepstatus == "Deferred"):
|
|
|
|
xepflag = "defer"
|
|
|
|
|
|
|
|
## SEND MAIL:
|
|
|
|
#
|
2007-01-16 18:35:34 -05:00
|
|
|
# From: editor@xmpp.org
|
|
|
|
# To: standards@xmpp.org
|
2006-10-02 18:22:13 -04:00
|
|
|
# Subject: UPDATED: XEP-$xepnum ($title)
|
|
|
|
# [or "NEW..." if version 0.1]
|
|
|
|
# Body:
|
|
|
|
# Version $version of XEP-$xepnum ($title) is now available.
|
|
|
|
# Abstract: $abstract
|
|
|
|
# Changelog: $remark ($initials)
|
2007-06-18 22:11:11 -04:00
|
|
|
# CVS Diff: $diffs
|
2009-03-31 18:03:04 -04:00
|
|
|
# URL: http://xmpp.org/extensions/xep-$xepnum.html
|
2006-10-02 18:22:13 -04:00
|
|
|
|
2007-01-16 18:35:34 -05:00
|
|
|
fromaddr = "editor@xmpp.org"
|
2006-10-02 18:22:13 -04:00
|
|
|
# for testing...
|
|
|
|
# toaddrs = "stpeter@jabber.org"
|
|
|
|
# for real...
|
2007-01-16 18:35:34 -05:00
|
|
|
toaddrs = "standards@xmpp.org"
|
2006-10-02 18:22:13 -04:00
|
|
|
|
|
|
|
if xepflag == "new":
|
|
|
|
thesubject = 'NEW: XEP-'
|
|
|
|
elif xepflag == "draft":
|
|
|
|
thesubject = 'DRAFT: XEP-'
|
|
|
|
elif xepflag == "final":
|
|
|
|
thesubject = 'FINAL: XEP-'
|
|
|
|
elif xepflag == "active":
|
|
|
|
thesubject = 'ACTIVE: XEP-'
|
|
|
|
elif xepflag == "retract":
|
|
|
|
thesubject = 'RETRACTED: XEP-'
|
2007-01-17 17:54:29 -05:00
|
|
|
elif xepflag == "deprecate":
|
|
|
|
thesubject = 'DEPRECATED: XEP-'
|
2006-10-02 18:22:13 -04:00
|
|
|
elif xepflag == "defer":
|
|
|
|
thesubject = 'DEFERRED: XEP-'
|
|
|
|
else:
|
|
|
|
thesubject = 'UPDATED: XEP-'
|
|
|
|
thesubject = thesubject + xepnum + ' (' + title + ')'
|
|
|
|
|
|
|
|
versionline = 'Version ' + version + ' of XEP-' + xepnum + ' (' + title + ') has been released.'
|
|
|
|
abstractline = 'Abstract: ' + abstract
|
|
|
|
changelogline = 'Changelog: ' + remark + ' (' + initials + ')'
|
2007-06-18 22:11:11 -04:00
|
|
|
diffsline = 'Diff: ' + diffs
|
2009-03-31 18:03:04 -04:00
|
|
|
urlline = 'URL: http://xmpp.org/extensions/xep-' + xepnum + '.html'
|
2006-10-02 18:22:13 -04:00
|
|
|
|
|
|
|
msg = "From: XMPP Extensions Editor <%s>\r\n" % fromaddr
|
|
|
|
msg = msg + "To: %s\r\n" % toaddrs
|
|
|
|
msg = msg + "Subject: %s\r\n" % thesubject
|
|
|
|
msg = msg + versionline
|
|
|
|
msg = msg + "\r\n\n"
|
|
|
|
msg = msg + abstractline
|
|
|
|
msg = msg + "\r\n\n"
|
|
|
|
msg = msg + changelogline
|
|
|
|
msg = msg + "\r\n\n"
|
2007-06-20 14:05:41 -04:00
|
|
|
msg = msg + diffsline
|
2006-10-02 18:22:13 -04:00
|
|
|
msg = msg + "\r\n\n"
|
|
|
|
msg = msg + urlline
|
|
|
|
msg = msg + "\r\n\n"
|
|
|
|
|
2007-01-31 12:45:33 -05:00
|
|
|
server = smtplib.SMTP('localhost')
|
|
|
|
server.set_debuglevel(1)
|
|
|
|
server.sendmail(fromaddr, toaddrs, msg)
|
|
|
|
server.quit()
|
2006-10-02 18:22:13 -04:00
|
|
|
|
|
|
|
# END
|
|
|
|
|