Merge branch 'experimental' of git@github.com:fritzy/SleekXMPP into experimental
This commit is contained in:
commit
2b6454786a
4 changed files with 8 additions and 10 deletions
|
@ -9,7 +9,6 @@ from __future__ import with_statement
|
||||||
from . import base
|
from . import base
|
||||||
import logging
|
import logging
|
||||||
from xml.etree import cElementTree as ET
|
from xml.etree import cElementTree as ET
|
||||||
import traceback
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class xep_0050(base.base_plugin):
|
class xep_0050(base.base_plugin):
|
||||||
|
|
|
@ -9,6 +9,7 @@ from .. xmlstream.stanzabase import StanzaBase
|
||||||
from xml.etree import cElementTree as ET
|
from xml.etree import cElementTree as ET
|
||||||
from . error import Error
|
from . error import Error
|
||||||
from .. exceptions import XMPPError
|
from .. exceptions import XMPPError
|
||||||
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ class RootStanza(StanzaBase):
|
||||||
self['error']['text'] = "SleekXMPP got into trouble."
|
self['error']['text'] = "SleekXMPP got into trouble."
|
||||||
else:
|
else:
|
||||||
self['error']['text'] = traceback.format_tb(e.__traceback__)
|
self['error']['text'] = traceback.format_tb(e.__traceback__)
|
||||||
|
logging.exception('Error handling {%s}%s stanza' % (self.namespace, self.name))
|
||||||
self.send()
|
self.send()
|
||||||
|
|
||||||
# all jabber:client root stanzas should have the error plugin
|
# all jabber:client root stanzas should have the error plugin
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
"""
|
"""
|
||||||
from xml.etree import cElementTree as ET
|
from xml.etree import cElementTree as ET
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
|
||||||
import sys
|
import sys
|
||||||
import weakref
|
import weakref
|
||||||
import copy
|
import copy
|
||||||
|
@ -379,7 +378,7 @@ class StanzaBase(ElementBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def exception(self, e):
|
def exception(self, e):
|
||||||
logging.error(traceback.format_tb(e))
|
logging.exception('Error handling {%s}%s stanza' % (self.namespace, self.name))
|
||||||
|
|
||||||
def send(self):
|
def send(self):
|
||||||
self.stream.sendRaw(self.__str__())
|
self.stream.sendRaw(self.__str__())
|
||||||
|
|
|
@ -19,7 +19,6 @@ import logging
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
|
||||||
import types
|
import types
|
||||||
import copy
|
import copy
|
||||||
import xml.sax.saxutils
|
import xml.sax.saxutils
|
||||||
|
@ -195,14 +194,14 @@ class XMLStream(object):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.state.set('processing', False)
|
self.state.set('processing', False)
|
||||||
traceback.print_exc()
|
logging.exception('Socket Error')
|
||||||
self.disconnect(reconnect=True)
|
self.disconnect(reconnect=True)
|
||||||
except:
|
except:
|
||||||
if not self.state.reconnect:
|
if not self.state.reconnect:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.state.set('processing', False)
|
self.state.set('processing', False)
|
||||||
traceback.print_exc()
|
logging.exception('Connection error. Reconnecting.')
|
||||||
self.disconnect(reconnect=True)
|
self.disconnect(reconnect=True)
|
||||||
if self.state['reconnect']:
|
if self.state['reconnect']:
|
||||||
self.reconnect()
|
self.reconnect()
|
||||||
|
@ -258,8 +257,7 @@ class XMLStream(object):
|
||||||
logging.warning("Failed to send %s" % data)
|
logging.warning("Failed to send %s" % data)
|
||||||
self.state.set('connected', False)
|
self.state.set('connected', False)
|
||||||
if self.state.reconnect:
|
if self.state.reconnect:
|
||||||
logging.error("Disconnected. Socket Error.")
|
logging.exception("Disconnected. Socket Error.")
|
||||||
traceback.print_exc()
|
|
||||||
self.disconnect(reconnect=True)
|
self.disconnect(reconnect=True)
|
||||||
|
|
||||||
def sendRaw(self, data):
|
def sendRaw(self, data):
|
||||||
|
@ -344,14 +342,14 @@ class XMLStream(object):
|
||||||
try:
|
try:
|
||||||
handler.run(args[0])
|
handler.run(args[0])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
logging.exception('Error processing event handler: %s' % handler.name)
|
||||||
args[0].exception(e)
|
args[0].exception(e)
|
||||||
elif etype == 'schedule':
|
elif etype == 'schedule':
|
||||||
try:
|
try:
|
||||||
logging.debug(args)
|
logging.debug(args)
|
||||||
handler(*args[0])
|
handler(*args[0])
|
||||||
except:
|
except:
|
||||||
logging.error(traceback.format_exc())
|
logging.exception('Error processing scheduled task')
|
||||||
elif etype == 'quit':
|
elif etype == 'quit':
|
||||||
logging.debug("Quitting eventRunner thread")
|
logging.debug("Quitting eventRunner thread")
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue