No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

deferred.py 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/usr/bin/env python
  2. # File: deferred.py
  3. # Version: 0.3
  4. # Description: a script for setting a XEP to Deferred
  5. # Last Modified: 2006-11-01
  6. # Author: Peter Saint-Andre (stpeter@jabber.org)
  7. # License: public domain
  8. # HowTo: ./deferred.py xepnum
  9. ## LICENSE ##
  10. #
  11. # Copyright (c) 1999 - 2010 XMPP Standards Foundation
  12. #
  13. # Permission is hereby granted, free of charge, to any person obtaining a copy
  14. # of this software and associated documentation files (the "Software"), to deal
  15. # in the Software without restriction, including without limitation the rights
  16. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17. # copies of the Software, and to permit persons to whom the Software is
  18. # furnished to do so, subject to the following conditions:
  19. #
  20. # The above copyright notice and this permission notice shall be included in
  21. # all copies or substantial portions of the Software.
  22. #
  23. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  28. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  29. # THE SOFTWARE.
  30. #
  31. ## END LICENSE ##
  32. # IMPORTS:
  33. #
  34. import glob
  35. import os
  36. from select import select
  37. import smtplib
  38. import socket
  39. from string import split,strip,join,find
  40. import sys
  41. import time
  42. from xml.dom.minidom import parse,parseString,Document
  43. def getText(nodelist):
  44. thisText = ""
  45. for node in nodelist:
  46. if node.nodeType == node.TEXT_NODE:
  47. thisText = thisText + node.data
  48. return thisText
  49. # get the seconds in the Unix era
  50. now = int(time.time())
  51. # READ IN ARGS:
  52. #
  53. # 1. XEP number
  54. xepnum = sys.argv[1];
  55. xepfile = 'xep-' + xepnum + '.xml'
  56. # PARSE XEP HEADERS:
  57. #
  58. # - title
  59. # - abstract
  60. # - version
  61. # - date
  62. # - initials
  63. # - remark
  64. thexep = parse(xepfile)
  65. xepNode = (thexep.getElementsByTagName("xep")[0])
  66. headerNode = (xepNode.getElementsByTagName("header")[0])
  67. titleNode = (headerNode.getElementsByTagName("title")[0])
  68. title = getText(titleNode.childNodes)
  69. abstractNode = (headerNode.getElementsByTagName("abstract")[0])
  70. abstract = getText(abstractNode.childNodes)
  71. statusNode = (headerNode.getElementsByTagName("status")[0])
  72. xepstatus = getText(statusNode.childNodes)
  73. typeNode = (headerNode.getElementsByTagName("type")[0])
  74. xeptype = getText(typeNode.childNodes)
  75. revNode = (headerNode.getElementsByTagName("revision")[0])
  76. versionNode = (revNode.getElementsByTagName("version")[0])
  77. version = getText(versionNode.childNodes)
  78. dateNode = (revNode.getElementsByTagName("date")[0])
  79. date = getText(dateNode.childNodes)
  80. initialsNode = (revNode.getElementsByTagName("initials")[0])
  81. initials = getText(initialsNode.childNodes)
  82. remarkNode = (revNode.getElementsByTagName("remark")[0])
  83. remark = getText(remarkNode.childNodes)
  84. # SEND MAIL:
  85. #
  86. # From: editor@xmpp.org
  87. # To: standards@xmpp.org
  88. # Subject: DEFERRED: XEP-$xepnum ($title)
  89. # Body:
  90. # XEP-$xepnum ($title) has been Deferred because of inactivity.
  91. #
  92. # Abstract: $abstract
  93. #
  94. # URL: https://xmpp.org/extensions/xep-$xepnum.html
  95. #
  96. # If and when a new revision of this XEP is published,
  97. # its status will be changed back to Experimental.
  98. #
  99. fromaddr = "editor@xmpp.org"
  100. # for testing...
  101. # toaddrs = "stpeter@jabber.org"
  102. # for real...
  103. toaddrs = "standards@xmpp.org"
  104. thesubject = 'DEFERRED: XEP-' + xepnum + " (" + title + ")"
  105. introline = 'XEP-' + xepnum + ' (' + title + ') has been Deferred because of inactivity.'
  106. abstractline = 'Abstract: ' + abstract
  107. urlline = 'URL: https://xmpp.org/extensions/xep-' + xepnum + '.html'
  108. endline = 'If and when a new revision of this XEP is published, its status will be changed back to Experimental.'
  109. #msg = "From: %s\r\n" % fromaddr
  110. msg = "From: XMPP Extensions Editor <%s>\r\n" % fromaddr
  111. msg = msg + "To: %s\r\n" % toaddrs
  112. msg = msg + "Subject: %s\r\n" % thesubject
  113. msg = msg + introline
  114. msg = msg + "\r\n\n"
  115. msg = msg + abstractline
  116. msg = msg + "\r\n\n"
  117. msg = msg + urlline
  118. msg = msg + "\r\n\n"
  119. msg = msg + endline
  120. msg = msg + "\r\n"
  121. server = smtplib.SMTP('localhost')
  122. server.set_debuglevel(1)
  123. server.sendmail(fromaddr, toaddrs, msg)
  124. server.quit()
  125. # END