diff --git a/jabberpy-python3.patch b/jabberpy-python3.patch index cd27032..d0371bd 100644 --- a/jabberpy-python3.patch +++ b/jabberpy-python3.patch @@ -1,5 +1,5 @@ diff --git jabberpy-0.5-0/jabber/debug.py jabberpy-0.5-0/jabber/debug.py -index 4615697..140612b 100644 +index 4615697..f4a28d2 100644 --- jabberpy-0.5-0/jabber/debug.py +++ jabberpy-0.5-0/jabber/debug.py @@ -43,7 +43,13 @@ import sys @@ -41,7 +41,27 @@ index 4615697..140612b 100644 sys.exit(0) else: ## assume its a stream type object self._fh = log_file -@@ -271,7 +277,7 @@ class Debug: +@@ -190,8 +196,7 @@ class Debug: + self._fh = sys.stdout + + if time_stamp not in (0,1,2): +- msg2 = '%s' % time_stamp +- raise 'Invalid time_stamp param', msg2 ++ raise Exception('Invalid time_stamp param: %s' % time_stamp) + self.prefix = prefix + self.sufix = sufix + self.time_stamp = time_stamp +@@ -214,8 +219,7 @@ class Debug: + if type(flag_show) in (type(''), type(None)): + self.flag_show = flag_show + else: +- msg2 = '%s' % type(flag_show ) +- raise 'Invalid type for flag_show!', msg2 ++ raise Exception('Invalid type for flag_show: %s' % type(flag_show)) + + + +@@ -271,7 +275,7 @@ class Debug: # dont print "None", just show the separator output = '%s %s' % ( output, self.flag_show ) @@ -50,7 +70,7 @@ index 4615697..140612b 100644 msg=msg.encode(self.encoding, 'replace') output = '%s%s%s' % ( output, msg, suf ) -@@ -321,11 +327,11 @@ class Debug: +@@ -321,11 +325,11 @@ class Debug: if not active_flags: #no debuging at all self.active = [] @@ -64,7 +84,7 @@ index 4615697..140612b 100644 else: ok_flags.append( t ) -@@ -360,7 +366,7 @@ class Debug: +@@ -360,7 +364,7 @@ class Debug: This code organises lst and remves dupes """ @@ -73,20 +93,35 @@ index 4615697..140612b 100644 return [ items ] r = [] for l in items: -@@ -377,7 +383,7 @@ class Debug: +@@ -377,9 +381,8 @@ class Debug: def _append_unique_str( self, lst, item ): """filter out any dupes.""" - if type(item) <> type(''): -+ if isinstance(item, StringType): - msg2 = '%s' % item - raise 'Invalid item type (should be string)',msg2 +- msg2 = '%s' % item +- raise 'Invalid item type (should be string)',msg2 ++ if not isinstance(item, StringType): ++ raise Exception('Invalid item type (should be string): %s' % type(item)) if item not in lst: + lst.append( item ) + return lst +@@ -389,9 +392,8 @@ class Debug: + 'verify that flag is defined.' + if flags: + for f in self._as_one_list( flags ): +- if not f in debug_flags: +- msg2 = '%s' % f +- raise 'Invalid debugflag given', msg2 ++ if f not in debug_flags: ++ raise Exception('Invalid debugflag given: %s' % f) + + def _remove_dupe_flags( self ): + """ diff --git jabberpy-0.5-0/jabber/jabber.py jabberpy-0.5-0/jabber/jabber.py -index ab9d9b3..405d92e 100644 +index ab9d9b3..af4dbd2 100644 --- jabberpy-0.5-0/jabber/jabber.py +++ jabberpy-0.5-0/jabber/jabber.py -@@ -64,9 +64,17 @@ An example of usage for a simple client would be ( only psuedo code !) +@@ -64,17 +64,22 @@ An example of usage for a simple client would be ( only psuedo code !) # $Id: jabber.py,v 1.58 2004/01/18 05:27:10 snakeru Exp $ @@ -105,7 +140,15 @@ index ab9d9b3..405d92e 100644 debug=xmlstream.debug -@@ -179,14 +187,14 @@ RS_EXT_PENDING = 0 + VERSION = xmlstream.VERSION + +-False = 0; +-True = 1; +- + timeout = 300 + + DBG_INIT, DBG_ALWAYS = debug.DBG_INIT, debug.DBG_ALWAYS +@@ -179,14 +184,14 @@ RS_EXT_PENDING = 0 def ustr(what): """If sending object is already a unicode str, just return it, otherwise convert it using xmlstream.ENCODING""" @@ -123,7 +166,7 @@ index ab9d9b3..405d92e 100644 return r xmlstream.ustr = ustr -@@ -218,17 +226,17 @@ class Connection(xmlstream.Client): +@@ -218,17 +223,17 @@ class Connection(xmlstream.Client): def setMessageHandler(self, func, type='', chainOutput=False): """Back compartibility method""" @@ -144,7 +187,7 @@ index ab9d9b3..405d92e 100644 return self.registerHandler('iq', func, type, ns) def header(self): -@@ -248,7 +256,7 @@ class Connection(xmlstream.Client): +@@ -248,7 +253,7 @@ class Connection(xmlstream.Client): def _expectedIqHandler(self, conn, iq_obj): if iq_obj.getAttr('id') and \ @@ -153,7 +196,7 @@ index ab9d9b3..405d92e 100644 self._expected[iq_obj.getAttr('id')] = iq_obj raise NodeProcessed('No need for further Iq processing.') -@@ -257,7 +265,7 @@ class Connection(xmlstream.Client): +@@ -257,7 +262,7 @@ class Connection(xmlstream.Client): Builds the relevant jabber.py object and dispatches it to a relevant function or callback.""" name=stanza.getName() @@ -162,7 +205,7 @@ index ab9d9b3..405d92e 100644 self.DEBUG("whats a tag -> " + name,DBG_NODE_UNKNOWN) name='unknown' else: -@@ -274,9 +282,9 @@ class Connection(xmlstream.Client): +@@ -274,9 +279,9 @@ class Connection(xmlstream.Client): self.DEBUG("dispatch called for: name->%s ns->%s"%(name,ns),DBG_DISPATCH) typns=typ+ns @@ -175,7 +218,7 @@ index ab9d9b3..405d92e 100644 chain=[] for key in ['default',typ,ns,typns]: # we will use all handlers: from very common to very particular -@@ -337,7 +345,7 @@ class Connection(xmlstream.Client): +@@ -337,7 +342,7 @@ class Connection(xmlstream.Client): have lower priority that common handlers. """ if not type and not ns: type='default' @@ -184,7 +227,7 @@ index ab9d9b3..405d92e 100644 if makefirst: self.handlers[name][type+ns].insert({'chain':chained,'func':handler,'system':system}) else: self.handlers[name][type+ns].append({'chain':chained,'func':handler,'system':system}) -@@ -526,7 +534,7 @@ class Client(Connection): +@@ -526,7 +531,7 @@ class Client(Connection): seq = auth_ret_query.getTag('sequence').getData() self.DEBUG("zero-k authentication supported",(DBG_INIT,DBG_NODE_IQ)) hash = hashlib.new('sha1', hashlib.new('sha1', passwd).hexdigest()+token).hexdigest() @@ -193,7 +236,7 @@ index ab9d9b3..405d92e 100644 q.insertTag('hash').insertData(hash) elif auth_ret_query.getTag('digest'): -@@ -729,7 +737,7 @@ class Protocol(xmlstream.Node): +@@ -729,7 +734,7 @@ class Protocol(xmlstream.Node): def asNode(self): """Back compartibility method""" @@ -202,7 +245,7 @@ index ab9d9b3..405d92e 100644 return self def getError(self): -@@ -822,7 +830,7 @@ class Protocol(xmlstream.Node): +@@ -822,7 +827,7 @@ class Protocol(xmlstream.Node): XML document""" x = self.setX(namespace) @@ -211,7 +254,7 @@ index ab9d9b3..405d92e 100644 payload = xmlstream.NodeBuilder(payload).getDom() x.kids = [] # should be a method for this realy -@@ -961,7 +969,7 @@ class Message(Protocol): +@@ -961,7 +966,7 @@ class Message(Protocol): return m def build_reply(self, reply_txt=''): @@ -220,7 +263,7 @@ index ab9d9b3..405d92e 100644 return self.buildReply(reply_txt) ############################################################################# -@@ -1059,7 +1067,7 @@ class Iq(Protocol): +@@ -1059,7 +1064,7 @@ class Iq(Protocol): if q is None: q = self.insertTag('query') @@ -229,7 +272,7 @@ index ab9d9b3..405d92e 100644 payload = xmlstream.NodeBuilder(payload).getDom() if not add: q.kids = [] -@@ -1138,7 +1146,7 @@ class Roster: +@@ -1138,7 +1143,7 @@ class Roster: def getStatus(self, jid): ## extended """Returns the 'status' value for a Roster item with the given jid.""" jid = ustr(jid) @@ -238,7 +281,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['status'] return None -@@ -1146,7 +1154,7 @@ class Roster: +@@ -1146,7 +1151,7 @@ class Roster: def getShow(self, jid): ## extended """Returns the 'show' value for a Roster item with the given jid.""" jid = ustr(jid) @@ -247,7 +290,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['show'] return None -@@ -1155,7 +1163,7 @@ class Roster: +@@ -1155,7 +1160,7 @@ class Roster: """Returns the 'online' status for a Roster item with the given jid. """ jid = ustr(jid) @@ -256,7 +299,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['online'] return None -@@ -1164,7 +1172,7 @@ class Roster: +@@ -1164,7 +1169,7 @@ class Roster: """Returns the 'subscription' status for a Roster item with the given jid.""" jid = ustr(jid) @@ -265,7 +308,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['sub'] return None -@@ -1172,7 +1180,7 @@ class Roster: +@@ -1172,7 +1177,7 @@ class Roster: def getName(self,jid): """Returns the 'name' for a Roster item with the given jid.""" jid = ustr(jid) @@ -274,7 +317,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['name'] return None -@@ -1181,7 +1189,7 @@ class Roster: +@@ -1181,7 +1186,7 @@ class Roster: """ Returns the lsit of groups associated with the given roster item. """ jid = ustr(jid) @@ -283,7 +326,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['groups'] return None -@@ -1189,7 +1197,7 @@ class Roster: +@@ -1189,7 +1194,7 @@ class Roster: def getAsk(self,jid): """Returns the 'ask' status for a Roster item with the given jid.""" jid = ustr(jid) @@ -292,7 +335,7 @@ index ab9d9b3..405d92e 100644 return self._data[jid]['ask'] return None -@@ -1233,7 +1241,7 @@ class Roster: +@@ -1233,7 +1238,7 @@ class Roster: jid = ustr(jid) # just in case online = 'offline' if ask: online = 'pending' @@ -301,7 +344,7 @@ index ab9d9b3..405d92e 100644 self._data[jid]['name'] = name self._data[jid]['groups'] = groups self._data[jid]['ask'] = ask -@@ -1255,13 +1263,13 @@ class Roster: +@@ -1255,13 +1260,13 @@ class Roster: def _setOnline(self,jid,val): """Used internally - private""" jid = ustr(jid) @@ -317,7 +360,7 @@ index ab9d9b3..405d92e 100644 self._data[jid_basic]['online'] = val if self._listener != None: self._listener("update", jid_basic, {'online' : val}) -@@ -1270,13 +1278,13 @@ class Roster: +@@ -1270,13 +1275,13 @@ class Roster: def _setShow(self,jid,val): """Used internally - private""" jid = ustr(jid) @@ -333,7 +376,7 @@ index ab9d9b3..405d92e 100644 self._data[jid_basic]['show'] = val if self._listener != None: self._listener("update", jid_basic, {'show' : val}) -@@ -1285,13 +1293,13 @@ class Roster: +@@ -1285,13 +1290,13 @@ class Roster: def _setStatus(self,jid,val): """Used internally - private""" jid = ustr(jid) @@ -349,7 +392,7 @@ index ab9d9b3..405d92e 100644 self._data[jid_basic]['status'] = val if self._listener != None: self._listener("update", jid_basic, {'status' : val}) -@@ -1299,7 +1307,7 @@ class Roster: +@@ -1299,7 +1304,7 @@ class Roster: def _remove(self,jid): """Used internally - private""" @@ -359,10 +402,10 @@ index ab9d9b3..405d92e 100644 if self._listener != None: self._listener("remove", jid, {}) diff --git jabberpy-0.5-0/jabber/xmlstream.py jabberpy-0.5-0/jabber/xmlstream.py -index e8fdcab..3ed2d3e 100644 +index e8fdcab..94079e7 100644 --- jabberpy-0.5-0/jabber/xmlstream.py +++ jabberpy-0.5-0/jabber/xmlstream.py -@@ -34,7 +34,10 @@ import time, sys, re, socket +@@ -34,14 +34,14 @@ import time, sys, re, socket from select import select from base64 import encodestring import xml.parsers.expat @@ -374,7 +417,14 @@ index e8fdcab..3ed2d3e 100644 _debug=debug VERSION = "0.5" -@@ -83,7 +86,7 @@ class Node: + +-False = 0 +-True = 1 +- + TCP = 1 + STDIO = 0 + TCP_SSL = 2 +@@ -83,7 +83,7 @@ class Node: """A simple XML DOM like class""" def __init__(self, tag=None, parent=None, attrs={}, payload=[], node=None): if node: @@ -383,7 +433,7 @@ index e8fdcab..3ed2d3e 100644 self.name,self.namespace,self.attrs,self.data,self.kids,self.parent = \ node.name,node.namespace,node.attrs,node.data,node.kids,node.parent else: -@@ -258,7 +261,7 @@ class NodeBuilder: +@@ -258,7 +258,7 @@ class NodeBuilder: self._ptr.kids.append(Node(tag=tag,parent=self._ptr,attrs=attrs)) self._ptr = self._ptr.kids[-1] else: ## it the stream tag: @@ -392,7 +442,7 @@ index e8fdcab..3ed2d3e 100644 self._incomingID = attrs['id'] self.last_is_data = False -@@ -322,7 +325,7 @@ class Stream(NodeBuilder): +@@ -322,7 +322,7 @@ class Stream(NodeBuilder): try: self._logFH = open(log,'w') except: @@ -401,7 +451,7 @@ index e8fdcab..3ed2d3e 100644 sys.exit(0) else: ## assume its a stream type object self._logFH = log -@@ -469,7 +472,7 @@ class Client(Stream): +@@ -469,7 +469,7 @@ class Client(Stream): af, socktype, proto, canonname, sa = r try: self._sock = socket.socket(af, socktype, proto) @@ -410,7 +460,7 @@ index e8fdcab..3ed2d3e 100644 self._sock = None continue try: -@@ -477,7 +480,8 @@ class Client(Stream): +@@ -477,7 +477,8 @@ class Client(Stream): self._sock.connect((self._proxy['host'], self._proxy['port'])) else: self._sock.connect((self._hostIP, self._port)) @@ -420,7 +470,7 @@ index e8fdcab..3ed2d3e 100644 self._sock.close() self._sock = None self.DEBUG("socket error: "+str(e),DBG_CONN_ERROR) -@@ -501,7 +505,7 @@ class Client(Stream): +@@ -501,7 +502,7 @@ class Client(Stream): if self._proxy: self.DEBUG("Proxy connected",DBG_INIT) @@ -429,7 +479,7 @@ index e8fdcab..3ed2d3e 100644 else: type = 'CONNECT' connector = [] if type == 'CONNECT': -@@ -515,7 +519,7 @@ class Client(Stream): +@@ -515,7 +516,7 @@ class Client(Stream): connector.append('Pragma: no-cache') connector.append('Host: %s:%s'%(self._hostIP,self._port)) connector.append('User-Agent: Jabberpy/'+VERSION) @@ -438,7 +488,7 @@ index e8fdcab..3ed2d3e 100644 credentials = '%s:%s'%(self._proxy['user'],self._proxy['password']) credentials = encodestring(credentials).strip() connector.append('Proxy-Authorization: Basic '+credentials) -@@ -526,7 +530,7 @@ class Client(Stream): +@@ -526,7 +527,7 @@ class Client(Stream): self._read , self._write = bak try: proto,code,desc=reply.split('\n')[0].split(' ',2) except: raise error('Invalid proxy reply') @@ -447,7 +497,7 @@ index e8fdcab..3ed2d3e 100644 while reply.find('\n\n') == -1: reply += self.read().replace('\r','') self.DEBUG("Jabber server connected",DBG_INIT) -@@ -574,16 +578,16 @@ class Server: +@@ -574,16 +575,16 @@ class Server: def serve(self): @@ -467,7 +517,7 @@ index e8fdcab..3ed2d3e 100644 self.readsocks.append(newsock) self._makeNewStream(newsock) # add to select list, wait -@@ -591,7 +595,7 @@ class Server: +@@ -591,7 +592,7 @@ class Server: # client socket: read next line data = sockobj.recv(1024) # recv should not block