[thorstenp] use != instead of <>
This commit is contained in:
parent
196dd7e30a
commit
992e90208e
15 changed files with 31 additions and 31 deletions
|
@ -124,7 +124,7 @@ class OldEntry(xmpp.Node, object):
|
||||||
''' Get the uri the entry points to (entry's first link element with rel='alternate'
|
''' Get the uri the entry points to (entry's first link element with rel='alternate'
|
||||||
or without rel attribute). '''
|
or without rel attribute). '''
|
||||||
for element in self.getTags('link'):
|
for element in self.getTags('link'):
|
||||||
if 'rel' in element.attrs and element.attrs['rel']<>'alternate': continue
|
if 'rel' in element.attrs and element.attrs['rel']!='alternate': continue
|
||||||
try:
|
try:
|
||||||
return element.attrs['href']
|
return element.attrs['href']
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -152,7 +152,7 @@ class SASL(PlugIn):
|
||||||
|
|
||||||
def SASLHandler(self,conn,challenge):
|
def SASLHandler(self,conn,challenge):
|
||||||
""" Perform next SASL auth step. Used internally. """
|
""" Perform next SASL auth step. Used internally. """
|
||||||
if challenge.getNamespace()<>NS_SASL: return
|
if challenge.getNamespace()!=NS_SASL: return
|
||||||
if challenge.getName()=='failure':
|
if challenge.getName()=='failure':
|
||||||
self.startsasl='failure'
|
self.startsasl='failure'
|
||||||
try: reason=challenge.getChildren()[0]
|
try: reason=challenge.getChildren()[0]
|
||||||
|
|
|
@ -168,7 +168,7 @@ class SASL(PlugIn):
|
||||||
|
|
||||||
def SASLHandler(self, conn, challenge):
|
def SASLHandler(self, conn, challenge):
|
||||||
''' Perform next SASL auth step. Used internally. '''
|
''' Perform next SASL auth step. Used internally. '''
|
||||||
if challenge.getNamespace() <> NS_SASL:
|
if challenge.getNamespace() != NS_SASL:
|
||||||
return
|
return
|
||||||
if challenge.getName() == 'failure':
|
if challenge.getName() == 'failure':
|
||||||
self.startsasl = 'failure'
|
self.startsasl = 'failure'
|
||||||
|
|
|
@ -112,8 +112,8 @@ class Browser(PlugIn):
|
||||||
if node is None: node=[None]
|
if node is None: node=[None]
|
||||||
else: node=node.replace('/',' /').split('/')
|
else: node=node.replace('/',' /').split('/')
|
||||||
for i in node:
|
for i in node:
|
||||||
if i<>'' and i in cur: cur=cur[i]
|
if i!='' and i in cur: cur=cur[i]
|
||||||
elif set and i<>'': cur[i]={dict:cur,str:i}; cur=cur[i]
|
elif set and i!='': cur[i]={dict:cur,str:i}; cur=cur[i]
|
||||||
elif set or '' in cur: return cur,''
|
elif set or '' in cur: return cur,''
|
||||||
else: return None,None
|
else: return None,None
|
||||||
if 1 in cur or set: return cur,1
|
if 1 in cur or set: return cur,1
|
||||||
|
|
|
@ -104,7 +104,7 @@ class CommonClient:
|
||||||
# Who initiated this client
|
# Who initiated this client
|
||||||
# Used to register the EventDispatcher
|
# Used to register the EventDispatcher
|
||||||
self._caller=caller
|
self._caller=caller
|
||||||
if debug and type(debug)<>list: debug=['always', 'nodebuilder']
|
if debug and type(debug)!=list: debug=['always', 'nodebuilder']
|
||||||
self._DEBUG=Debug.Debug(debug)
|
self._DEBUG=Debug.Debug(debug)
|
||||||
self.DEBUG=self._DEBUG.Show
|
self.DEBUG=self._DEBUG.Show
|
||||||
self.debug_flags=self._DEBUG.debug_flags
|
self.debug_flags=self._DEBUG.debug_flags
|
||||||
|
@ -203,7 +203,7 @@ class Client(CommonClient):
|
||||||
If you want to disable tls/ssl support completely, set it to 0.
|
If you want to disable tls/ssl support completely, set it to 0.
|
||||||
Example: connect(('192.168.5.5',5222),{'host':'proxy.my.net','port':8080,'user':'me','password':'secret'})
|
Example: connect(('192.168.5.5',5222),{'host':'proxy.my.net','port':8080,'user':'me','password':'secret'})
|
||||||
Returns '' or 'tcp' or 'tls', depending on the result."""
|
Returns '' or 'tcp' or 'tls', depending on the result."""
|
||||||
if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure<>None and not secure: return self.connected
|
if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure!=None and not secure: return self.connected
|
||||||
transports.TLS().PlugIn(self)
|
transports.TLS().PlugIn(self)
|
||||||
if 'version' not in self.Dispatcher.Stream._document_attrs or not self.Dispatcher.Stream._document_attrs['version']=='1.0': return self.connected
|
if 'version' not in self.Dispatcher.Stream._document_attrs or not self.Dispatcher.Stream._document_attrs['version']=='1.0': return self.connected
|
||||||
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
|
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
|
||||||
|
|
|
@ -329,7 +329,7 @@ class Debug:
|
||||||
|
|
||||||
This code organises lst and remves dupes
|
This code organises lst and remves dupes
|
||||||
"""
|
"""
|
||||||
if type( items ) <> type( [] ) and type( items ) <> type( () ):
|
if type( items ) != type( [] ) and type( items ) != type( () ):
|
||||||
return [ items ]
|
return [ items ]
|
||||||
r = []
|
r = []
|
||||||
for l in items:
|
for l in items:
|
||||||
|
@ -346,7 +346,7 @@ class Debug:
|
||||||
|
|
||||||
def _append_unique_str( self, lst, item ):
|
def _append_unique_str( self, lst, item ):
|
||||||
"""filter out any dupes."""
|
"""filter out any dupes."""
|
||||||
if type(item) <> type(''):
|
if type(item) != type(''):
|
||||||
msg2 = '%s' % item
|
msg2 = '%s' % item
|
||||||
raise 'Invalid item type (should be string)',msg2
|
raise 'Invalid item type (should be string)',msg2
|
||||||
if item not in lst:
|
if item not in lst:
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Dispatcher(PlugIn):
|
||||||
self._owner.send("<?xml version='1.0'?>%s>"%str(self._metastream)[:-2])
|
self._owner.send("<?xml version='1.0'?>%s>"%str(self._metastream)[:-2])
|
||||||
|
|
||||||
def _check_stream_start(self,ns,tag,attrs):
|
def _check_stream_start(self,ns,tag,attrs):
|
||||||
if ns<>NS_STREAMS or tag<>'stream':
|
if ns!=NS_STREAMS or tag!='stream':
|
||||||
raise ValueError('Incorrect stream start: (%s,%s). Terminating.'%(tag,ns))
|
raise ValueError('Incorrect stream start: (%s,%s). Terminating.'%(tag,ns))
|
||||||
|
|
||||||
def Process(self, timeout=0):
|
def Process(self, timeout=0):
|
||||||
|
@ -300,7 +300,7 @@ class Dispatcher(PlugIn):
|
||||||
session.DEBUG("Expected stanza arrived. Callback %s(%s) found!"%(cb,args),'ok')
|
session.DEBUG("Expected stanza arrived. Callback %s(%s) found!"%(cb,args),'ok')
|
||||||
try: cb(session,stanza,**args)
|
try: cb(session,stanza,**args)
|
||||||
except Exception, typ:
|
except Exception, typ:
|
||||||
if typ.__class__.__name__<>'NodeProcessed': raise
|
if typ.__class__.__name__!='NodeProcessed': raise
|
||||||
else:
|
else:
|
||||||
session.DEBUG("Expected stanza arrived!",'ok')
|
session.DEBUG("Expected stanza arrived!",'ok')
|
||||||
session._expected[ID]=stanza
|
session._expected[ID]=stanza
|
||||||
|
@ -310,7 +310,7 @@ class Dispatcher(PlugIn):
|
||||||
try:
|
try:
|
||||||
handler['func'](session,stanza)
|
handler['func'](session,stanza)
|
||||||
except Exception, typ:
|
except Exception, typ:
|
||||||
if typ.__class__.__name__<>'NodeProcessed':
|
if typ.__class__.__name__!='NodeProcessed':
|
||||||
self._pendingExceptions.insert(0, sys.exc_info())
|
self._pendingExceptions.insert(0, sys.exc_info())
|
||||||
return
|
return
|
||||||
user=0
|
user=0
|
||||||
|
|
|
@ -117,7 +117,7 @@ class Dispatcher(PlugIn):
|
||||||
self._owner.send("<?xml version='1.0'?>%s>" % str(self._metastream)[:-2])
|
self._owner.send("<?xml version='1.0'?>%s>" % str(self._metastream)[:-2])
|
||||||
|
|
||||||
def _check_stream_start(self, ns, tag, attrs):
|
def _check_stream_start(self, ns, tag, attrs):
|
||||||
if ns<>NS_STREAMS or tag<>'stream':
|
if ns!=NS_STREAMS or tag!='stream':
|
||||||
raise ValueError('Incorrect stream start: (%s,%s). Terminating.' % (tag, ns))
|
raise ValueError('Incorrect stream start: (%s,%s). Terminating.' % (tag, ns))
|
||||||
|
|
||||||
def ProcessNonBlocking(self, data=None):
|
def ProcessNonBlocking(self, data=None):
|
||||||
|
@ -343,7 +343,7 @@ class Dispatcher(PlugIn):
|
||||||
try:
|
try:
|
||||||
cb(session,stanza,**args)
|
cb(session,stanza,**args)
|
||||||
except Exception, typ:
|
except Exception, typ:
|
||||||
if typ.__class__.__name__ <>'NodeProcessed': raise
|
if typ.__class__.__name__ !='NodeProcessed': raise
|
||||||
else:
|
else:
|
||||||
session.DEBUG("Expected stanza arrived!",'ok')
|
session.DEBUG("Expected stanza arrived!",'ok')
|
||||||
session._expected[ID]=stanza
|
session._expected[ID]=stanza
|
||||||
|
@ -354,7 +354,7 @@ class Dispatcher(PlugIn):
|
||||||
try:
|
try:
|
||||||
handler['func'](session,stanza)
|
handler['func'](session,stanza)
|
||||||
except Exception, typ:
|
except Exception, typ:
|
||||||
if typ.__class__.__name__ <> 'NodeProcessed':
|
if typ.__class__.__name__ != 'NodeProcessed':
|
||||||
self._pendingExceptions.insert(0, sys.exc_info())
|
self._pendingExceptions.insert(0, sys.exc_info())
|
||||||
return
|
return
|
||||||
user=0
|
user=0
|
||||||
|
|
|
@ -101,7 +101,7 @@ def _ReceivedRegInfo(con, resp, agent):
|
||||||
return
|
return
|
||||||
df=DataForm(typ='form')
|
df=DataForm(typ='form')
|
||||||
for i in resp.getQueryPayload():
|
for i in resp.getQueryPayload():
|
||||||
if type(i)<>type(iq): pass
|
if type(i)!=type(iq): pass
|
||||||
elif i.getName()=='instructions': df.addInstructions(i.getData())
|
elif i.getName()=='instructions': df.addInstructions(i.getData())
|
||||||
else: df.setField(i.getName()).setValue(i.getData())
|
else: df.setField(i.getName()).setValue(i.getData())
|
||||||
con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,df,False))
|
con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,df,False))
|
||||||
|
@ -114,7 +114,7 @@ def register(disp,host,info):
|
||||||
attributes lastErrNode, lastErr and lastErrCode.
|
attributes lastErrNode, lastErr and lastErrCode.
|
||||||
"""
|
"""
|
||||||
iq=Iq('set',NS_REGISTER,to=host)
|
iq=Iq('set',NS_REGISTER,to=host)
|
||||||
if type(info)<>type({}): info=info.asDict()
|
if type(info)!=type({}): info=info.asDict()
|
||||||
for i in info.keys(): iq.setTag('query').setTagData(i,info[i])
|
for i in info.keys(): iq.setTag('query').setTagData(i,info[i])
|
||||||
resp=disp.SendAndWaitForResponse(iq)
|
resp=disp.SendAndWaitForResponse(iq)
|
||||||
if isResultNode(resp): return 1
|
if isResultNode(resp): return 1
|
||||||
|
|
|
@ -147,7 +147,7 @@ class IBB(PlugIn):
|
||||||
else:
|
else:
|
||||||
stream=self._streams[sid]
|
stream=self._streams[sid]
|
||||||
if not data: err=ERR_BAD_REQUEST
|
if not data: err=ERR_BAD_REQUEST
|
||||||
elif seq<>stream['seq']: err=ERR_UNEXPECTED_REQUEST
|
elif seq!=stream['seq']: err=ERR_UNEXPECTED_REQUEST
|
||||||
else:
|
else:
|
||||||
self.DEBUG('Successfull receive sid->%s %s+%s bytes'%(sid,stream['fp'].tell(),len(data)),'ok')
|
self.DEBUG('Successfull receive sid->%s %s+%s bytes'%(sid,stream['fp'].tell(),len(data)),'ok')
|
||||||
stream['seq']+=1
|
stream['seq']+=1
|
||||||
|
|
|
@ -372,7 +372,7 @@ class Protocol(Node):
|
||||||
errtag=self.getTag('error')
|
errtag=self.getTag('error')
|
||||||
if errtag:
|
if errtag:
|
||||||
for tag in errtag.getChildren():
|
for tag in errtag.getChildren():
|
||||||
if tag.getName()<>'text': return tag.getName()
|
if tag.getName()!='text': return tag.getName()
|
||||||
return errtag.getData()
|
return errtag.getData()
|
||||||
def getErrorMsg(self):
|
def getErrorMsg(self):
|
||||||
""" Return the textual description of the error (if present) or the error condition """
|
""" Return the textual description of the error (if present) or the error condition """
|
||||||
|
|
|
@ -238,9 +238,9 @@ class Session:
|
||||||
self.sendnow(text+'>')
|
self.sendnow(text+'>')
|
||||||
self.set_stream_state(STREAM__OPENED)
|
self.set_stream_state(STREAM__OPENED)
|
||||||
if self.TYP=='client': return
|
if self.TYP=='client': return
|
||||||
if tag<>'stream': return self.terminate_stream(STREAM_INVALID_XML)
|
if tag!='stream': return self.terminate_stream(STREAM_INVALID_XML)
|
||||||
if ns<>NS_STREAMS: return self.terminate_stream(STREAM_INVALID_NAMESPACE)
|
if ns!=NS_STREAMS: return self.terminate_stream(STREAM_INVALID_NAMESPACE)
|
||||||
if self.Stream.xmlns<>self.xmlns: return self.terminate_stream(STREAM_BAD_NAMESPACE_PREFIX)
|
if self.Stream.xmlns!=self.xmlns: return self.terminate_stream(STREAM_BAD_NAMESPACE_PREFIX)
|
||||||
if 'to' not in attrs: return self.terminate_stream(STREAM_IMPROPER_ADDRESSING)
|
if 'to' not in attrs: return self.terminate_stream(STREAM_IMPROPER_ADDRESSING)
|
||||||
if attrs['to'] not in self._owner.servernames: return self.terminate_stream(STREAM_HOST_UNKNOWN)
|
if attrs['to'] not in self._owner.servernames: return self.terminate_stream(STREAM_HOST_UNKNOWN)
|
||||||
self.ourname=attrs['to'].lower()
|
self.ourname=attrs['to'].lower()
|
||||||
|
@ -320,7 +320,7 @@ class Session:
|
||||||
|
|
||||||
def stop_feature(self,f):
|
def stop_feature(self,f):
|
||||||
""" Declare some feature as "negotiated" to allow other features start negotiating. """
|
""" Declare some feature as "negotiated" to allow other features start negotiating. """
|
||||||
if self.feature_in_process<>f: raise "Stopping feature %s instead of %s !"%(f,self.feature_in_process)
|
if self.feature_in_process!=f: raise "Stopping feature %s instead of %s !"%(f,self.feature_in_process)
|
||||||
self.feature_in_process=None
|
self.feature_in_process=None
|
||||||
|
|
||||||
def set_socket_state(self,newstate):
|
def set_socket_state(self,newstate):
|
||||||
|
|
|
@ -30,7 +30,7 @@ def ustr(what):
|
||||||
if isinstance(what, unicode): return what
|
if isinstance(what, unicode): return what
|
||||||
try: r=what.__str__()
|
try: r=what.__str__()
|
||||||
except AttributeError: r=str(what)
|
except AttributeError: r=str(what)
|
||||||
if type(r)<>type(u''): return unicode(r,ENCODING)
|
if type(r)!=type(u''): return unicode(r,ENCODING)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
class Node(object):
|
class Node(object):
|
||||||
|
@ -214,10 +214,10 @@ class Node(object):
|
||||||
Returns the list of nodes found. """
|
Returns the list of nodes found. """
|
||||||
nodes=[]
|
nodes=[]
|
||||||
for node in self.kids:
|
for node in self.kids:
|
||||||
if namespace and namespace<>node.getNamespace(): continue
|
if namespace and namespace!=node.getNamespace(): continue
|
||||||
if node.getName() == name:
|
if node.getName() == name:
|
||||||
for key in attrs.keys():
|
for key in attrs.keys():
|
||||||
if key not in node.attrs or node.attrs[key]<>attrs[key]: break
|
if key not in node.attrs or node.attrs[key]!=attrs[key]: break
|
||||||
else: nodes.append(node)
|
else: nodes.append(node)
|
||||||
if one and nodes: return nodes[0]
|
if one and nodes: return nodes[0]
|
||||||
if not one: return nodes
|
if not one: return nodes
|
||||||
|
|
|
@ -139,7 +139,7 @@ class TCPsocket(PlugIn):
|
||||||
""" Writes raw outgoing data. Blocks until done.
|
""" Writes raw outgoing data. Blocks until done.
|
||||||
If supplied data is unicode string, encodes it to utf-8 before send."""
|
If supplied data is unicode string, encodes it to utf-8 before send."""
|
||||||
if isinstance(raw_data, unicode): raw_data = raw_data.encode('utf-8')
|
if isinstance(raw_data, unicode): raw_data = raw_data.encode('utf-8')
|
||||||
elif type(raw_data)<>type(str): raw_data = ustr(raw_data).encode('utf-8')
|
elif type(raw_data)!=type(str): raw_data = ustr(raw_data).encode('utf-8')
|
||||||
try:
|
try:
|
||||||
self._send(raw_data)
|
self._send(raw_data)
|
||||||
# Avoid printing messages that are empty keepalive packets.
|
# Avoid printing messages that are empty keepalive packets.
|
||||||
|
@ -207,7 +207,7 @@ class HTTPPROXYsocket(TCPsocket):
|
||||||
return
|
return
|
||||||
try: proto,code,desc=reply.split('\n')[0].split(' ',2)
|
try: proto,code,desc=reply.split('\n')[0].split(' ',2)
|
||||||
except: raise error('Invalid proxy reply')
|
except: raise error('Invalid proxy reply')
|
||||||
if code<>'200':
|
if code!='200':
|
||||||
self.DEBUG('Invalid proxy reply: %s %s %s'%(proto,code,desc),'error')
|
self.DEBUG('Invalid proxy reply: %s %s %s'%(proto,code,desc),'error')
|
||||||
self._owner.disconnected()
|
self._owner.disconnected()
|
||||||
return
|
return
|
||||||
|
@ -278,7 +278,7 @@ class TLS(PlugIn):
|
||||||
def StartTLSHandler(self, conn, starttls):
|
def StartTLSHandler(self, conn, starttls):
|
||||||
""" Handle server reply if TLS is allowed to process. Behaves accordingly.
|
""" Handle server reply if TLS is allowed to process. Behaves accordingly.
|
||||||
Used internally."""
|
Used internally."""
|
||||||
if starttls.getNamespace()<>NS_TLS: return
|
if starttls.getNamespace()!=NS_TLS: return
|
||||||
self.starttls=starttls.getName()
|
self.starttls=starttls.getName()
|
||||||
if self.starttls=='failure':
|
if self.starttls=='failure':
|
||||||
self.DEBUG("Got starttls response: "+self.starttls,'error')
|
self.DEBUG("Got starttls response: "+self.starttls,'error')
|
||||||
|
|
|
@ -850,7 +850,7 @@ class NonBlockingTLS(PlugIn):
|
||||||
def StartTLSHandler(self, conn, starttls):
|
def StartTLSHandler(self, conn, starttls):
|
||||||
''' Handle server reply if TLS is allowed to process. Behaves accordingly.
|
''' Handle server reply if TLS is allowed to process. Behaves accordingly.
|
||||||
Used internally.'''
|
Used internally.'''
|
||||||
if starttls.getNamespace() <> NS_TLS:
|
if starttls.getNamespace() != NS_TLS:
|
||||||
return
|
return
|
||||||
self.starttls = starttls.getName()
|
self.starttls = starttls.getName()
|
||||||
if self.starttls == 'failure':
|
if self.starttls == 'failure':
|
||||||
|
@ -925,7 +925,7 @@ class NBHTTPPROXYsocket(NonBlockingTcp):
|
||||||
#traceback.print_exc()
|
#traceback.print_exc()
|
||||||
self.on_proxy_failure('Invalid proxy reply')
|
self.on_proxy_failure('Invalid proxy reply')
|
||||||
return
|
return
|
||||||
if code <> '200':
|
if code != '200':
|
||||||
self.DEBUG('Invalid proxy reply: %s %s %s' % (proto, code, desc),'error')
|
self.DEBUG('Invalid proxy reply: %s %s %s' % (proto, code, desc),'error')
|
||||||
self._owner.disconnected()
|
self._owner.disconnected()
|
||||||
self.on_proxy_failure('Invalid proxy reply')
|
self.on_proxy_failure('Invalid proxy reply')
|
||||||
|
|
Loading…
Add table
Reference in a new issue