| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ License |
|---|
| 4 |
##~ |
|---|
| 5 |
##- The RuneBlade Foundation library is intended to ease some |
|---|
| 6 |
##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.) |
|---|
| 7 |
##- applications, while providing the flexibility to modularly change the |
|---|
| 8 |
##- architecture. Enjoy. |
|---|
| 9 |
##~ |
|---|
| 10 |
##~ Copyright (C) 2002 TechGame Networks, LLC. |
|---|
| 11 |
##~ |
|---|
| 12 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 13 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 14 |
##~ LICENSE file included with this distribution. |
|---|
| 15 |
##~ |
|---|
| 16 |
##~ TechGame Networks, LLC can be reached at: |
|---|
| 17 |
##~ 3578 E. Hartsel Drive #211 |
|---|
| 18 |
##~ Colorado Springs, Colorado, USA, 80920 |
|---|
| 19 |
##~ |
|---|
| 20 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 |
#~ Imports |
|---|
| 24 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 25 |
|
|---|
| 26 |
import logging as _logging |
|---|
| 27 |
|
|---|
| 28 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 29 |
#~ Definitions |
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
|
|---|
| 32 |
class RBTelepathyError(StandardError): |
|---|
| 33 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 34 |
#~ Constants / Variables / Etc. |
|---|
| 35 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 36 |
|
|---|
| 37 |
__slots__ = ('message', 'log', 'report', 'reraise', 'shutdown') |
|---|
| 38 |
|
|---|
| 39 |
message = 'Unknown Error' |
|---|
| 40 |
logtype = _logging.DEBUG |
|---|
| 41 |
logtraceback = False |
|---|
| 42 |
report = True |
|---|
| 43 |
shutdown = False |
|---|
| 44 |
#errortype = property(_get_errortype) |
|---|
| 45 |
|
|---|
| 46 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 47 |
#~ Public |
|---|
| 48 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 49 |
|
|---|
| 50 |
def __init__(self, message, **kw): |
|---|
| 51 |
self.message = message |
|---|
| 52 |
for name, value in kw.iteritems(): |
|---|
| 53 |
setattr(self, name, value) |
|---|
| 54 |
|
|---|
| 55 |
def __str__(self): |
|---|
| 56 |
return self.message |
|---|
| 57 |
|
|---|
| 58 |
def GetStreamHeader(self): |
|---|
| 59 |
return self._toXML() |
|---|
| 60 |
|
|---|
| 61 |
def GetStreamData(self): |
|---|
| 62 |
return '' |
|---|
| 63 |
|
|---|
| 64 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 65 |
#~ Protected Methods |
|---|
| 66 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 67 |
|
|---|
| 68 |
def _toXML(self, *args, **kw): |
|---|
| 69 |
return '' |
|---|
| 70 |
|
|---|
| 71 |
def _get_errortype(self): |
|---|
| 72 |
return self.__class__.__name__ |
|---|
| 73 |
errortype = property(_get_errortype) |
|---|
| 74 |
|
|---|
| 75 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 76 |
|
|---|
| 77 |
class StreamError(RBTelepathyError): |
|---|
| 78 |
pass |
|---|
| 79 |
class StreamProtocolError(StreamError): |
|---|
| 80 |
pass |
|---|
| 81 |
class StreamQuotaError(StreamError): |
|---|
| 82 |
log = _logging.WARN |
|---|
| 83 |
|
|---|
| 84 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 85 |
|
|---|
| 86 |
class PacketError(StreamProtocolError): |
|---|
| 87 |
shutdown = True |
|---|
| 88 |
class PacketIncompleteError(PacketError): |
|---|
| 89 |
shutdown = True |
|---|
| 90 |
class PacketInvalidXMLError(PacketError): |
|---|
| 91 |
shutdown = True |
|---|
| 92 |
class PacketMalformedError(PacketError): |
|---|
| 93 |
shutdown = False |
|---|
| 94 |
|
|---|
| 95 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 96 |
|
|---|
| 97 |
class ConnectionError(RBTelepathyError): |
|---|
| 98 |
pass |
|---|
| 99 |
class AuthenticationError(ConnectionError): |
|---|
| 100 |
log = _logging.WARN |
|---|
| 101 |
shutdown = True |
|---|
| 102 |
class PermissionsError(ConnectionError): |
|---|
| 103 |
log = _logging.WARN |
|---|
| 104 |
class PacketHandlerError(ConnectionError): |
|---|
| 105 |
pass |
|---|
| 106 |
|
|---|
| 107 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 108 |
|
|---|
| 109 |
class RoutingError(ConnectionError): |
|---|
| 110 |
pass |
|---|