def __init__(self, endpoint, server=None, port=None, use_srv=True, wait=80, hold=4, requests=5, headers=None, PIPELINE=True, GZIP=True): PlugIn.__init__(self) self.DBG_LINE = 'bosh' self._exported_methods = [ self.send, self.receive, self.disconnect, ] url = urlparse(endpoint) self._http_host = url.hostname self._http_path = url.path if url.port: self._http_port = url.port elif url.scheme == 'https': self._http_port = 443 else: self._http_port = 80 self._http_proto = url.scheme self._server = server self._port = port self.use_srv = use_srv self.Sid = None self._rid = 0 self.wait = wait self.hold = hold self.requests = requests self._pipeline = None self.PIPELINE = PIPELINE if self.PIPELINE: self._respobjs = [] else: self._respobjs = {} self.headers = headers or self.default_headers self.GZIP = GZIP
def __init__(self, browser): """Initialises class and sets up local variables""" PlugIn.__init__(self) DBG_LINE='commands' self._exported_methods=[] self._handlers={'':{}} self._browser = browser
def __init__(self): PlugIn.__init__(self) DBG_LINE = "dispatcher" self.handlers = {} self._expected = {} self._defaultHandler = None self._pendingExceptions = [] self._eventHandler = None self._cycleHandlers = [] self._exported_methods = [ self.Process, self.RegisterHandler, self.RegisterDefaultHandler, self.RegisterEventHandler, self.UnregisterCycleHandler, self.RegisterCycleHandler, self.RegisterHandlerOnce, self.UnregisterHandler, self.RegisterProtocol, self.WaitForResponse, self.SendAndWaitForResponse, self.send, self.disconnect, self.SendAndCallForResponse, ]
def __init__(self): """ Init internal variables. """ PlugIn.__init__(self) self.DBG_LINE = 'roster' self._data = {} self.set = None self._exported_methods = [self.getRoster]
def __init__(self, browser): """Initialises class and sets up local variables""" PlugIn.__init__(self) DBG_LINE = 'commands' self._exported_methods = [] self._handlers = {'': {}} self._browser = browser
def __init__(self,user,password,resource): """ Caches username, password and resource for auth. """ PlugIn.__init__(self) self.DBG_LINE='gen_auth' self.user=user self.password=password self.resource=resource
def __init__(self): """ Init internal variables. """ PlugIn.__init__(self) self.DBG_LINE='roster' self._data = {} self.set=None self._exported_methods=[self.getRoster]
def __init__(self, user, password, resource, on_auth): ''' Caches username, password and resource for auth. ''' PlugIn.__init__(self) self.DBG_LINE ='gen_auth' self.user = user self.password= password self.resource = resource self.on_auth = on_auth
def __init__(self, server=None, use_srv=True): """ Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. """ PlugIn.__init__(self) self.DBG_LINE = 'socket' self._exported_methods = [self.send, self.disconnect] self._server = server
def __init__(self, server=None, use_srv=True): """ Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. """ PlugIn.__init__(self) self.DBG_LINE='socket' self._exported_methods=[self.send,self.disconnect] self._server = server
def __init__(self,jid=''): """Set up the class""" PlugIn.__init__(self) DBG_LINE='command' self.sessioncount = 0 self.sessions = {} # Disco information for command list pre-formatted as a tuple self.discoinfo = {'ids':[{'category':'automation','type':'command-node','name':self.description}],'features': self.discofeatures} self._jid = jid
def __init__(self, server=None, use_srv=True): """ Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. However library will lookup for ('_xmpp-client._tcp.' + host) SRV record in DNS and connect to the found (if it is) server instead """ PlugIn.__init__(self) self.DBG_LINE = 'socket' self._exported_methods = [self.send, self.disconnect] self._server, self.use_srv = server, use_srv
def __init__(self, server=None, use_srv=True): """ Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. However library will lookup for ('_xmpp-client._tcp.' + host) SRV record in DNS and connect to the found (if it is) server instead """ PlugIn.__init__(self) self.DBG_LINE='socket' self._exported_methods=[self.send,self.disconnect] self._server, self.use_srv = server, use_srv
def __init__(self, jid=""): """Set up the class""" PlugIn.__init__(self) DBG_LINE = "command" self.sessioncount = 0 self.sessions = {} # Disco information for command list pre-formatted as a tuple self.discoinfo = { "ids": [{"category": "automation", "type": "command-node", "name": self.description}], "features": self.discofeatures, } self._jid = jid
def __init__(self): PlugIn.__init__(self) DBG_LINE='dispatcher' self.handlers={} self._expected={} self._defaultHandler=None self._eventHandler=None self._cycleHandlers=[] self._exported_methods=[self.Process,self.RegisterHandler,self.RegisterDefaultHandler,\ self.RegisterEventHandler,self.UnregisterCycleHandler,self.RegisterCycleHandler,\ self.RegisterHandlerOnce,self.UnregisterHandler,self.RegisterProtocol,\ self.WaitForResponse,self.SendAndWaitForResponse,self.send,self.disconnect]
def __init__(self, endpoint, server=None, port=None, use_srv=True, wait=80, hold=4, requests=5, headers=None, PIPELINE=True, GZIP=True): PlugIn.__init__(self) self.DBG_LINE = 'bosh' self._exported_methods = [ self.send, self.receive, self.disconnect, ] url = urlparse(endpoint) self._http_host = url.hostname self._http_path = url.path if url.port: self._http_port = url.port elif url.scheme == 'https': self._http_port = 443 else: self._http_port = 80 self._http_proto = url.scheme self._server = server self._port = port self.use_srv = use_srv self.Sid = None self._rid = 0 self.wait = 80 self.hold = hold self.requests = requests self._pipeline = None self.PIPELINE = PIPELINE if self.PIPELINE: self._respobjs = [] else: self._respobjs = {} self.headers = headers or self.default_headers self.GZIP = GZIP
def PlugIn(self, owner, now=0): if owner.__dict__.has_key('TLS'): return # Already enabled. PlugIn.PlugIn(self, owner) DBG_LINE = 'TLS' if now: return self._startSSL() if self._owner.Dispatcher.Stream.features: self.FeaturesHandler(self._owner.Dispatcher, self._owner.Dispatcher.Stream.features) else: self._owner.RegisterHandlerOnce('features', self.FeaturesHandler) self.starttls = None
def __init__(self, on_connect = None, on_connect_failure = None, server=None, use_srv = True): ''' Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. on_connect - called when we connect to the socket on_connect_failure - called if there was error connecting to socket ''' IdleObject.__init__(self) PlugIn.__init__(self) self.DBG_LINE='socket' self._exported_methods=[self.send, self.disconnect, self.onreceive, self.set_send_timeout, self.start_disconnect, self.set_timeout, self.remove_timeout] self._server = server self.on_connect = on_connect self.on_connect_failure = on_connect_failure self.on_receive = None self.on_disconnect = None self.printed_error = False # 0 - not connected # 1 - connected # -1 - about to disconnect (when we wait for final events to complete) # -2 - disconnected self.state = 0 # queue with messages to be send self.sendqueue = [] # bytes remained from the last send message self.sendbuff = '' # time to wait for SOME stanza to come and then send keepalive self.sendtimeout = 0 # in case we want to something different than sending keepalives self.on_timeout = None # writable, readable - keep state of the last pluged flags # This prevents replug of same object with the same flags self.writable = True self.readable = False self.ais = None
def __init__(self, server=None, use_srv=True): """ Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. """ PlugIn.__init__(self) self.DBG_LINE='socket' self._exported_methods=[self.send,self.disconnect] # SRV resolver if use_srv and (HAVE_DNSPYTHON or HAVE_PYDNS): host, port = server possible_queries = ['_xmpp-client._tcp.' + host] for query in possible_queries: try: if HAVE_DNSPYTHON: answers = [x for x in dns.resolver.query(query, 'SRV')] if answers: host = str(answers[0].target) port = int(answers[0].port) break elif HAVE_PYDNS: # ensure we haven't cached an old configuration DNS.ParseResolvConf() response = DNS.Request().req(query, qtype='SRV') answers = response.answers if len(answers) > 0: # ignore the priority and weight for now _, _, port, host = answers[0]['data'] del _ port = int(port) break except: #TODO: use self.DEBUG() print 'An error occurred while looking up %s' % query server = (host, port) # end of SRV resolver self._server = server
def __init__(self, server=None, use_srv=True): """ Cache connection point 'server'. 'server' is the tuple of (host, port) absolutely the same as standard tcp socket uses. """ PlugIn.__init__(self) self.DBG_LINE = 'socket' self._exported_methods = [self.send, self.disconnect] # SRV resolver if use_srv and (HAVE_DNSPYTHON or HAVE_PYDNS): host, port = server possible_queries = ['_xmpp-client._tcp.' + host] for query in possible_queries: try: if HAVE_DNSPYTHON: answers = [x for x in dns.resolver.query(query, 'SRV')] if answers: host = str(answers[0].target) port = int(answers[0].port) break elif HAVE_PYDNS: # ensure we haven't cached an old configuration DNS.ParseResolvConf() response = DNS.Request().req(query, qtype='SRV') answers = response.answers if len(answers) > 0: # ignore the priority and weight for now _, _, port, host = answers[0]['data'] del _ port = int(port) break except: #TODO: use self.DEBUG() print 'An error occurred while looking up %s' % query server = (host, port) # end of SRV resolver self._server = server
def PlugIn(self,owner,now=0): """ If the 'now' argument is true then starts using encryption immidiatedly. If 'now' in false then starts encryption as soon as TLS feature is declared by the server (if it were already declared - it is ok). """ if owner.__dict__.has_key('TLS'): return # Already enabled. PlugIn.PlugIn(self,owner) DBG_LINE='TLS' if now: return self._startSSL() if self._owner.Dispatcher.Stream.features: try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features) except NodeProcessed: pass else: self._owner.RegisterHandlerOnce('features',self.FeaturesHandler,xmlns=NS_STREAMS) self.starttls=None
def __init__(self, server=None): PlugIn.__init__(self) self.DBG_LINE='socket' self._exported_methods=[self.send,self.disconnect] self._server = server
def __init__(self): PlugIn.__init__(self) self.DBG_LINE = 'roster' self._data = {} self.set = None self._exported_methods = [self.getRoster]
def __init__(self): """Initialises internal variables. Used internally.""" PlugIn.__init__(self) DBG_LINE = 'browser' self._exported_methods = [] self._handlers = {'': {}}
def __init__(self, username, password): PlugIn.__init__(self) self.DBG_LINE = 'SASL_auth' self.username = username self.password = password self.startsasl = None
def __init__(self): """Initialises internal variables. Used internally.""" PlugIn.__init__(self) DBG_LINE='browser' self._exported_methods=[] self._handlers={'':{}}
def __init__(self): PlugIn.__init__(self) self.DBG_LINE='roster' self._data = {} self.set=None self._exported_methods=[self.getRoster]
def __init__(self, server=None): PlugIn.__init__(self) self.DBG_LINE = 'socket' self._exported_methods = [self.send, self.disconnect] self._server = server
def __init__(self,username,password): PlugIn.__init__(self) self.username=username self.password=password
def __init__(self, username, password): PlugIn.__init__(self) self.DBG_LINE = "SASL_auth" self.username = username self.password = password self.startsasl = None
def __init__(self, sasl): PlugIn.__init__(self) self.DBG_LINE='bind' self.bound=None self.needsUnregister=None self.sasl = sasl
def __init__(self): PlugIn.__init__(self) self.DBG_LINE='bind' self.bound=None
def __init__(self, user, password, resource): PlugIn.__init__(self) self.DBG_LINE = "gen_auth" self.user = user self.password = password self.resource = resource
def __init__(self,username,password, on_sasl): PlugIn.__init__(self) self.username=username self.password=password self.on_sasl = on_sasl self.realm = None
def __init__(self): PlugIn.__init__(self) DBG_LINE = 'browser' self._exported_methods = [] self._handlers = {'': {}}
def __init__(self,user,password,resource): PlugIn.__init__(self) self.DBG_LINE='gen_auth' self.user=user self.password=password self.resource=resource