Select Git revision
02-remove-xmpp.patch
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
02-remove-xmpp.patch 4.12 KiB
diff --git a/painintheapt b/painintheapt
index 5fd816d..505b160 100755
--- a/painintheapt
+++ b/painintheapt
@@ -23,7 +23,6 @@ import urllib.request
# additional modules
import apt
import prettytable
-import sleekxmpp
longname = "Pain in the APT"
shortname = "painintheapt"
@@ -118,54 +117,6 @@ def maketable(lst):
return table.get_string()
-class JabberBot(sleekxmpp.ClientXMPP):
- def __init__(self, jid, password, to, room, pubsub_service, pubsub_node,
- nick, subject, message):
- sleekxmpp.ClientXMPP.__init__(self, jid, password)
- self.to = to
- self.room = room
- self.pubsub_service = pubsub_service
- self.pubsub_node = pubsub_node
- self.nick = nick
- self.add_event_handler("session_start", self.start)
- self.subject = subject
- self.message = message
-
- def start(self, event):
- self.getRoster()
- self.sendPresence()
- for to in self.to:
- self.send_message(
- mto=to,
- msubject=self.subject,
- # subject is not shown by all clients, better add it to body
- mbody="\n".join([self.subject, self.message]),
- mtype='chat')
- if self.room:
- self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
- self.send_message(
- mto=self.room,
- # no per message subject in groupchats, add it to message body
- mbody="\n".join([self.subject, self.message]),
- mtype='groupchat')
- if self.pubsub_service and self.pubsub_node:
- payload = '<entry xmlns="http://www.w3.org/2005/Atom"><title>' \
- + html.escape(self.subject) \
- + '</title><content type="xhtml">' \
- + '<pre xmlns="http://www.w3.org/1999/xhtml">' \
- + html.escape(self.message) \
- + '</pre></content></entry>'
- self['xep_0060'].publish(
- self.pubsub_service, self.pubsub_node,
- payload=sleekxmpp.xmlstream.ET.fromstring(payload))
- try:
- self.disconnect(wait=True)
- except TypeError: # older SleekXMPP doesn't have "wait"
- import time
- time.sleep(10)
- self.disconnect()
-
-
def read_password(config, config_dir):
password_file = config.get("password_file", "").strip()
if len(password_file):
@@ -177,31 +128,6 @@ def read_password(config, config_dir):
return config.get("password", "")
-def sendxmpp(config, config_dir, table, count, host, debug, changes):
- """Send message to a jabber conference room."""
- jid = config.get("jid", "")
- password = read_password(config, config_dir)
- to = config.get("to", "").split(",")
- room = config.get("room")
- pubsub_service = config.get("pubsub_service", "").strip()
- pubsub_node = config.get("pubsub_node", "").strip()
- subject = '%d package update(s) for %s' % (count, host)
- xmpp = JabberBot(
- jid, password, to, room, pubsub_service, pubsub_node,
- longname, subject, "\n\n".join([table, changes]).strip())
- xmpp.register_plugin('xep_0030') # service discovery
- if room:
- xmpp.register_plugin('xep_0045') # multi-user chat
- if pubsub_service and pubsub_node:
- xmpp.register_plugin('xep_0060') # pubsub
- xmpp.register_plugin('xep_0199') # XMPP ping
-
- if xmpp.connect():
- xmpp.process(threaded=False)
- else:
- raise("XMPP connect() failed")
-
-
def sendsmtp(config, config_dir, table, count, host, debug, changes):
"""Send email by SMTP to whomsoever it may concern."""
server = config.get("server", "localhost")
@@ -326,8 +252,7 @@ if __name__ == '__main__':
change, newhash = has_changed(args.configfile, table, args.stampfile)
ret = 0
- for section, function in [("XMPP", sendxmpp),
- ("HTTP", sendhttpjson),
+ for section, function in [("HTTP", sendhttpjson),
("SMTP", sendsmtp),
("MAILX", sendmailx)]:
try: