migrate to new logging part I

This commit is contained in:
Tobias Oberstein 2016-01-27 22:20:57 +01:00
parent 29f17f24e7
commit 71e85509cb
65 changed files with 119 additions and 148 deletions

View File

@ -79,7 +79,7 @@ class ApplicationRunner(object):
"""
def __init__(self, url, realm, extra=None, serializers=None,
debug=False, debug_wamp=False, debug_app=False,
debug=False, debug_app=False,
ssl=None):
"""
:param url: The WebSocket URL of the WAMP router to connect to (e.g. `ws://somehost.com:8090/somepath`)
@ -98,9 +98,6 @@ class ApplicationRunner(object):
:param debug: Turn on low-level debugging.
:type debug: bool
:param debug_wamp: Turn on WAMP-level debugging.
:type debug_wamp: bool
:param debug_app: Turn on app-level debugging.
:type debug_app: bool
@ -118,7 +115,6 @@ class ApplicationRunner(object):
self.extra = extra or dict()
self.serializers = serializers
self.debug = debug
self.debug_wamp = debug_wamp
self.debug_app = debug_app
self.ssl = ssl
@ -157,7 +153,7 @@ class ApplicationRunner(object):
# 2) create a WAMP-over-WebSocket transport client factory
transport_factory = WampWebSocketClientFactory(create, url=self.url, serializers=self.serializers,
debug=self.debug, debug_wamp=self.debug_wamp)
debug=self.debug)
# 3) start the client
loop = asyncio.get_event_loop()

View File

@ -288,9 +288,8 @@ class WampWebSocketServerFactory(websocket.WampWebSocketServerFactory, WebSocket
def __init__(self, factory, *args, **kwargs):
serializers = kwargs.pop('serializers', None)
debug_wamp = kwargs.pop('debug_wamp', False)
websocket.WampWebSocketServerFactory.__init__(self, factory, serializers, debug_wamp=debug_wamp)
websocket.WampWebSocketServerFactory.__init__(self, factory, serializers)
kwargs['protocols'] = self._protocols
@ -314,9 +313,8 @@ class WampWebSocketClientFactory(websocket.WampWebSocketClientFactory, WebSocket
def __init__(self, factory, *args, **kwargs):
serializers = kwargs.pop('serializers', None)
debug_wamp = kwargs.pop('debug_wamp', False)
websocket.WampWebSocketClientFactory.__init__(self, factory, serializers, debug_wamp=debug_wamp)
websocket.WampWebSocketClientFactory.__init__(self, factory, serializers)
kwargs['protocols'] = self._protocols

View File

@ -92,7 +92,7 @@ class ApplicationRunner(object):
log = txaio.make_logger()
def __init__(self, url, realm, extra=None, serializers=None,
debug=False, debug_wamp=False, debug_app=False,
debug=False, debug_app=False,
ssl=None, proxy=None):
"""
@ -112,9 +112,6 @@ class ApplicationRunner(object):
:param debug: Turn on low-level debugging.
:type debug: bool
:param debug_wamp: Turn on WAMP-level debugging.
:type debug_wamp: bool
:param debug_app: Turn on app-level debugging.
:type debug_app: bool
@ -139,7 +136,6 @@ class ApplicationRunner(object):
self.extra = extra or dict()
self.serializers = serializers
self.debug = debug
self.debug_wamp = debug_wamp
self.debug_app = debug_app
self.ssl = ssl
self.proxy = proxy
@ -172,7 +168,7 @@ class ApplicationRunner(object):
txaio.use_twisted()
txaio.config.loop = reactor
if self.debug or self.debug_wamp or self.debug_app:
if self.debug or self.debug_app:
txaio.start_logging(level='debug')
else:
txaio.start_logging(level='info')
@ -199,7 +195,7 @@ class ApplicationRunner(object):
# create a WAMP-over-WebSocket transport client factory
transport_factory = WampWebSocketClientFactory(create, url=self.url, serializers=self.serializers,
proxy=self.proxy, debug=self.debug, debug_wamp=self.debug_wamp)
proxy=self.proxy, debug=self.debug)
# supress pointless log noise like
# "Starting factory <autobahn.twisted.websocket.WampWebSocketClientFactory object at 0x2b737b480e10>""
@ -381,7 +377,7 @@ class Application(object):
return self.session
def run(self, url=u"ws://localhost:8080/ws", realm=u"realm1",
debug=False, debug_wamp=False, debug_app=False,
debug=False, debug_app=False,
start_reactor=True):
"""
Run the application.
@ -392,13 +388,11 @@ class Application(object):
:type realm: unicode
:param debug: Turn on low-level debugging.
:type debug: bool
:param debug_wamp: Turn on WAMP-level debugging.
:type debug_wamp: bool
:param debug_app: Turn on app-level debugging.
:type debug_app: bool
"""
runner = ApplicationRunner(url, realm,
debug=debug, debug_wamp=debug_wamp, debug_app=debug_app)
debug=debug, debug_app=debug_app)
runner.run(self.__call__, start_reactor)
def register(self, uri=None):
@ -570,7 +564,7 @@ if service:
factory = WampWebSocketClientFactory
def __init__(self, url, realm, make, extra=None, context_factory=None,
debug=False, debug_wamp=False, debug_app=False):
debug=False, debug_app=False):
"""
:param url: The WebSocket URL of the WAMP router to connect to (e.g. `ws://somehost.com:8090/somepath`)
@ -593,9 +587,6 @@ if service:
:param debug: Turn on low-level debugging.
:type debug: bool
:param debug_wamp: Turn on WAMP-level debugging.
:type debug_wamp: bool
:param debug_app: Turn on app-level debugging.
:type debug_app: bool
@ -606,7 +597,6 @@ if service:
self.realm = realm
self.extra = extra or dict()
self.debug = debug
self.debug_wamp = debug_wamp
self.debug_app = debug_app
self.make = make
self.context_factory = context_factory
@ -627,8 +617,7 @@ if service:
return session
# create a WAMP-over-WebSocket transport client factory
transport_factory = self.factory(create, url=self.url,
debug=self.debug, debug_wamp=self.debug_wamp)
transport_factory = self.factory(create, url=self.url, debug=self.debug)
# setup the client from a Twisted endpoint

View File

@ -590,9 +590,8 @@ class WampWebSocketServerFactory(websocket.WampWebSocketServerFactory, WebSocket
def __init__(self, factory, *args, **kwargs):
serializers = kwargs.pop('serializers', None)
debug_wamp = kwargs.pop('debug_wamp', False)
websocket.WampWebSocketServerFactory.__init__(self, factory, serializers, debug_wamp=debug_wamp)
websocket.WampWebSocketServerFactory.__init__(self, factory, serializers)
kwargs['protocols'] = self._protocols
@ -616,9 +615,8 @@ class WampWebSocketClientFactory(websocket.WampWebSocketClientFactory, WebSocket
def __init__(self, factory, *args, **kwargs):
serializers = kwargs.pop('serializers', None)
debug_wamp = kwargs.pop('debug_wamp', False)
websocket.WampWebSocketClientFactory.__init__(self, factory, serializers, debug_wamp=debug_wamp)
websocket.WampWebSocketClientFactory.__init__(self, factory, serializers)
kwargs['protocols'] = self._protocols

View File

@ -431,7 +431,7 @@ class Hello(Message):
"""
Return a string representation of this message.
"""
return "WAMP HELLO Message (realm = {0}, roles = {1}, authmethods = {2}, authid = {3}, authrole = {4}, authextra = {5})".format(self.realm, self.roles, self.authmethods, self.authid, self.authrole, self.authextra)
return u"Hello(realm={0}, roles={1}, authmethods={2}, authid={3}, authrole={4}, authextra={5})".format(self.realm, self.roles, self.authmethods, self.authid, self.authrole, self.authextra)
class Welcome(Message):
@ -603,7 +603,7 @@ class Welcome(Message):
"""
Returns string representation of this message.
"""
return "WAMP WELCOME Message (session = {0}, roles = {1}, realm = {2}, authid = {3}, authrole = {4}, authmethod = {5}, authprovider = {6}, authextra = {7})".format(self.session, self.roles, self.realm, self.authid, self.authrole, self.authmethod, self.authprovider, self.authextra)
return u"Welcome(session={0}, roles={1}, realm={2}, authid={3}, authrole={4}, authmethod={5}, authprovider={6}, authextra={7})".format(self.session, self.roles, self.realm, self.authid, self.authrole, self.authmethod, self.authprovider, self.authextra)
class Abort(Message):
@ -683,7 +683,7 @@ class Abort(Message):
"""
Returns string representation of this message.
"""
return "WAMP ABORT Message (message = {0}, reason = {1})".format(self.message, self.reason)
return u"Abort(message={0}, reason={1})".format(self.message, self.reason)
class Challenge(Message):
@ -752,7 +752,7 @@ class Challenge(Message):
"""
Returns string representation of this message.
"""
return "WAMP CHALLENGE Message (method = {0}, extra = {1})".format(self.method, self.extra)
return u"Challenge(method={0}, extra={1})".format(self.method, self.extra)
class Authenticate(Message):
@ -821,7 +821,7 @@ class Authenticate(Message):
"""
Returns string representation of this message.
"""
return "WAMP AUTHENTICATE Message (signature = {0}, extra = {1})".format(self.signature, self.extra)
return u"Authenticate(signature={0}, extra={1})".format(self.signature, self.extra)
class Goodbye(Message):
@ -906,7 +906,7 @@ class Goodbye(Message):
"""
Returns string representation of this message.
"""
return "WAMP GOODBYE Message (message = {0}, reason = {1})".format(self.message, self.reason)
return u"Goodbye(message={0}, reason={1})".format(self.message, self.reason)
class Error(Message):
@ -1080,7 +1080,7 @@ class Error(Message):
"""
Returns string representation of this message.
"""
return "WAMP ERROR Message (request_type = {0}, request = {1}, error = {2}, args = {3}, kwargs = {4}, enc_algo = {5}, enc_key = {6}, enc_serializer = {7}, payload = {8})".format(self.request_type, self.request, self.error, self.args, self.kwargs, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Error(request_type={0}, request={1}, error={2}, args={3}, kwargs={4}, enc_algo={5}, enc_key={6}, enc_serializer={7}, payload={8})".format(self.request_type, self.request, self.error, self.args, self.kwargs, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
class Publish(Message):
@ -1349,7 +1349,7 @@ class Publish(Message):
"""
Returns string representation of this message.
"""
return "WAMP PUBLISH Message (request = {0}, topic = {1}, args = {2}, kwargs = {3}, acknowledge = {4}, exclude_me = {5}, exclude = {6}, eligible = {7}, disclose_me = {8}, enc_algo = {9}, enc_key = {10}, enc_serializer = {11}, payload = {12})".format(self.request, self.topic, self.args, self.kwargs, self.acknowledge, self.exclude_me, self.exclude, self.eligible, self.disclose_me, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Publish(request={0}, topic={1}, args={2}, kwargs={3}, acknowledge={4}, exclude_me={5}, exclude={6}, eligible={7}, disclose_me={8}, enc_algo={9}, enc_key={10}, enc_serializer={11}, payload={12})".format(self.request, self.topic, self.args, self.kwargs, self.acknowledge, self.exclude_me, self.exclude, self.eligible, self.disclose_me, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
class Published(Message):
@ -1415,7 +1415,7 @@ class Published(Message):
"""
Returns string representation of this message.
"""
return "WAMP PUBLISHED Message (request = {0}, publication = {1})".format(self.request, self.publication)
return u"Published(request={0}, publication={1})".format(self.request, self.publication)
class Subscribe(Message):
@ -1509,7 +1509,7 @@ class Subscribe(Message):
"""
Returns string representation of this message.
"""
return "WAMP SUBSCRIBE Message (request = {0}, topic = {1}, match = {2})".format(self.request, self.topic, self.match)
return u"Subscribe(request={0}, topic={1}, match={2})".format(self.request, self.topic, self.match)
class Subscribed(Message):
@ -1575,7 +1575,7 @@ class Subscribed(Message):
"""
Returns string representation of this message.
"""
return "WAMP SUBSCRIBED Message (request = {0}, subscription = {1})".format(self.request, self.subscription)
return u"Subscribed(request={0}, subscription={1})".format(self.request, self.subscription)
class Unsubscribe(Message):
@ -1641,7 +1641,7 @@ class Unsubscribe(Message):
"""
Returns string representation of this message.
"""
return "WAMP UNSUBSCRIBE Message (request = {0}, subscription = {1})".format(self.request, self.subscription)
return u"Unsubscribe(request={0}, subscription={1})".format(self.request, self.subscription)
class Unsubscribed(Message):
@ -1740,7 +1740,7 @@ class Unsubscribed(Message):
"""
Returns string representation of this message.
"""
return "WAMP UNSUBSCRIBED Message (request = {0}, reason = {1}, subscription = {2})".format(self.request, self.reason, self.subscription)
return u"Unsubscribed(request={0}, reason={1}, subscription={2})".format(self.request, self.reason, self.subscription)
class Event(Message):
@ -1936,7 +1936,7 @@ class Event(Message):
"""
Returns string representation of this message.
"""
return "WAMP EVENT Message (subscription = {0}, publication = {1}, args = {2}, kwargs = {3}, publisher = {4}, topic = {5}, enc_algo = {6}, enc_key = {7}, enc_serializer = {8}, payload = {9})".format(self.subscription, self.publication, self.args, self.kwargs, self.publisher, self.topic, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Event(subscription={0}, publication={1}, args={2}, kwargs={3}, publisher={4}, topic={5}, enc_algo={6}, enc_key={7}, enc_serializer={8}, payload={9})".format(self.subscription, self.publication, self.args, self.kwargs, self.publisher, self.topic, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
class Call(Message):
@ -2165,7 +2165,7 @@ class Call(Message):
"""
Returns string representation of this message.
"""
return "WAMP CALL Message (request = {0}, procedure = {1}, args = {2}, kwargs = {3}, timeout = {4}, receive_progress = {5}, disclose_me = {6}, enc_algo = {7}, enc_key = {8}, enc_serializer = {9}, payload = {10})".format(self.request, self.procedure, self.args, self.kwargs, self.timeout, self.receive_progress, self.disclose_me, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Call(request={0}, procedure={1}, args={2}, kwargs={3}, timeout={4}, receive_progress={5}, disclose_me={6}, enc_algo={7}, enc_key={8}, enc_serializer={9}, payload={10})".format(self.request, self.procedure, self.args, self.kwargs, self.timeout, self.receive_progress, self.disclose_me, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
class Cancel(Message):
@ -2256,7 +2256,7 @@ class Cancel(Message):
"""
Returns string representation of this message.
"""
return "WAMP CANCEL Message (request = {0}, mode = '{1}'')".format(self.request, self.mode)
return u"Cancel(request={0}, mode={1})".format(self.request, self.mode)
class Result(Message):
@ -2431,7 +2431,7 @@ class Result(Message):
"""
Returns string representation of this message.
"""
return "WAMP RESULT Message (request = {0}, args = {1}, kwargs = {2}, progress = {3}, enc_algo = {4}, enc_key = {5}, enc_serializer = {6}, payload = {7})".format(self.request, self.args, self.kwargs, self.progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Result(request={0}, args={1}, kwargs={2}, progress={3}, enc_algo={4}, enc_key={5}, enc_serializer={6}, payload={7})".format(self.request, self.args, self.kwargs, self.progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
class Register(Message):
@ -2568,7 +2568,7 @@ class Register(Message):
"""
Returns string representation of this message.
"""
return "WAMP REGISTER Message (request = {0}, procedure = {1}, match = {2}, invoke = {3})".format(self.request, self.procedure, self.match, self.invoke)
return u"Register(request={0}, procedure={1}, match={2}, invoke={3})".format(self.request, self.procedure, self.match, self.invoke)
class Registered(Message):
@ -2634,7 +2634,7 @@ class Registered(Message):
"""
Returns string representation of this message.
"""
return "WAMP REGISTERED Message (request = {0}, registration = {1})".format(self.request, self.registration)
return u"Registered(request={0}, registration={1})".format(self.request, self.registration)
class Unregister(Message):
@ -2700,7 +2700,7 @@ class Unregister(Message):
"""
Returns string representation of this message.
"""
return "WAMP UNREGISTER Message (request = {0}, registration = {1})".format(self.request, self.registration)
return u"Unregister(request={0}, registration={1})".format(self.request, self.registration)
class Unregistered(Message):
@ -2798,7 +2798,7 @@ class Unregistered(Message):
"""
Returns string representation of this message.
"""
return "WAMP UNREGISTERED Message (request = {0}, reason = {1}, registration = {2})".format(self.request, self.reason, self.registration)
return u"Unregistered(request={0}, reason={1}, registration={2})".format(self.request, self.reason, self.registration)
class Invocation(Message):
@ -3044,7 +3044,7 @@ class Invocation(Message):
"""
Returns string representation of this message.
"""
return "WAMP INVOCATION Message (request = {0}, registration = {1}, args = {2}, kwargs = {3}, timeout = {4}, receive_progress = {5}, caller = {6}, procedure = {7}, enc_algo = {8}, enc_key = {9}, enc_serializer = {10}, payload = {11})".format(self.request, self.registration, self.args, self.kwargs, self.timeout, self.receive_progress, self.caller, self.procedure, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Invocation(request={0}, registration={1}, args={2}, kwargs={3}, timeout={4}, receive_progress={5}, caller={6}, procedure={7}, enc_algo={8}, enc_key={9}, enc_serializer={10}, payload={11})".format(self.request, self.registration, self.args, self.kwargs, self.timeout, self.receive_progress, self.caller, self.procedure, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
class Interrupt(Message):
@ -3134,7 +3134,7 @@ class Interrupt(Message):
"""
Returns string representation of this message.
"""
return "WAMP INTERRUPT Message (request = {0}, mode = '{1}')".format(self.request, self.mode)
return u"Interrupt(request={0}, mode={1})".format(self.request, self.mode)
class Yield(Message):
@ -3309,4 +3309,4 @@ class Yield(Message):
"""
Returns string representation of this message.
"""
return "WAMP YIELD Message (request = {0}, args = {1}, kwargs = {2}, progress = {3}, enc_algo = {4}, enc_key = {5}, enc_serializer = {6}, payload = {7})".format(self.request, self.args, self.kwargs, self.progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
return u"Yield(request={0}, args={1}, kwargs={2}, progress={3}, enc_algo={4}, enc_key={5}, enc_serializer={6}, payload={7})".format(self.request, self.args, self.kwargs, self.progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))

View File

@ -207,7 +207,6 @@ if os.environ.get('USE_TWISTED', False):
realm=self.realm,
make=component,
debug=bool(os.environ.get('debug_websocket', False)),
debug_wamp=bool(os.environ.get('debug_lowlevel', False)),
debug_app=bool(os.environ.get('debug_app', False))
)
c.setServiceParent(app)

View File

@ -47,8 +47,7 @@ class WampWebSocketProtocol(object):
_session = None # default; self.session is set in onOpen
def _bailout(self, code, reason=None):
if self.factory.debug_wamp:
print("Failing WAMP-over-WebSocket transport: code = {0}, reason = '{1}'".format(code, reason))
self.log.debug('Failing WAMP-over-WebSocket transport: code={code}, reason="{reason}"', code=code, reason=reason)
self.failConnection(code, reason)
def onOpen(self):
@ -62,8 +61,7 @@ class WampWebSocketProtocol(object):
self._session.onOpen(self)
except Exception as e:
self.log.critical(traceback.format_exc())
# Exceptions raised in onOpen are fatal ..
reason = "WAMP Internal Error ({0})".format(e)
reason = u'WAMP Internal Error ({0})'.format(e)
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_INTERNAL_ERROR, reason=reason)
def onClose(self, wasClean, code, reason):
@ -76,12 +74,10 @@ class WampWebSocketProtocol(object):
# session close callback
# noinspection PyBroadException
try:
if self.factory.debug_wamp:
print("WAMP-over-WebSocket transport lost: wasClean = {0}, code = {1}, reason = '{2}'".format(wasClean, code, reason))
self.log.debug('WAMP-over-WebSocket transport lost: wasClean={wasClean}, code={code}, reason="{reason}"', wasClean=wasClean, code=code, reason=reason)
self._session.onClose(wasClean)
except Exception:
print("Error invoking onClose():")
traceback.print_exc()
self.log.critical(traceback.format_exc())
self._session = None
def onMessage(self, payload, isBinary):
@ -90,20 +86,17 @@ class WampWebSocketProtocol(object):
"""
try:
for msg in self._serializer.unserialize(payload, isBinary):
if self.factory.debug_wamp:
print("RX {0}".format(msg))
self.log.trace("WAMP RECV: message={message}, session={session}, authid={authid}", authid=self._session._authid, session=self._session._session_id, message=msg)
self._session.onMessage(msg)
except ProtocolError as e:
print(e)
if self.factory.debug_wamp:
traceback.print_exc()
reason = "WAMP Protocol Error ({0})".format(e)
self.log.critical(traceback.format_exc())
reason = u'WAMP Protocol Error ({0})'.format(e)
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_PROTOCOL_ERROR, reason=reason)
except Exception as e:
self.log.critical(traceback.format_exc())
reason = "WAMP Internal Error ({0})".format(e)
reason = u'WAMP Internal Error ({0})'.format(e)
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_INTERNAL_ERROR, reason=reason)
def send(self, msg):
@ -112,13 +105,12 @@ class WampWebSocketProtocol(object):
"""
if self.isOpen():
try:
if self.factory.debug_wamp:
print("TX {0}".format(msg))
self.log.trace("WAMP SEND: message={message}, session={session}, authid={authid}", authid=self._session._authid, session=self._session._session_id, message=msg)
payload, isBinary = self._serializer.serialize(msg)
except Exception as e:
self.log.failure("Serialization failure")
self.log.failure("WAMP message serialization error")
# all exceptions raised from above should be serialization errors ..
raise SerializationError("WAMP serialization error ({0})".format(e))
raise SerializationError(u"WAMP message serialization error: {0}".format(e))
else:
self.sendMessage(payload, isBinary)
else:
@ -154,11 +146,11 @@ ITransport.register(WampWebSocketProtocol)
def parseSubprotocolIdentifier(subprotocol):
try:
s = subprotocol.split('.')
if s[0] != "wamp":
raise Exception("invalid protocol %s" % s[0])
s = subprotocol.split(u'.')
if s[0] != u'wamp':
raise Exception(u'WAMP WebSocket subprotocol identifier must start with "wamp", not "{}"'.format(s[0]))
version = int(s[1])
serializerId = '.'.join(s[2:])
serializerId = u'.'.join(s[2:])
return version, serializerId
except:
return None, None
@ -183,10 +175,10 @@ class WampWebSocketServerProtocol(WampWebSocketProtocol):
return subprotocol, headers
if self.STRICT_PROTOCOL_NEGOTIATION:
raise ConnectionDeny(ConnectionDeny.BAD_REQUEST, u'This server only speaks WebSocket subprotocols {0}'.format(u', '.join(self.factory.protocols)))
raise ConnectionDeny(ConnectionDeny.BAD_REQUEST, u'This server only speaks WebSocket subprotocols {}'.format(u', '.join(self.factory.protocols)))
else:
# assume wamp.2.json
self._serializer = self.factory._serializers['json']
self._serializer = self.factory._serializers[u'json']
return None, headers
@ -203,10 +195,10 @@ class WampWebSocketClientProtocol(WampWebSocketProtocol):
"""
if response.protocol not in self.factory.protocols:
if self.STRICT_PROTOCOL_NEGOTIATION:
raise Exception("Server does not speak any of the WebSocket subprotocols we requested (%s)." % ', '.join(self.factory.protocols))
raise Exception(u'The server does not speak any of the WebSocket subprotocols {} we requested.'.format(u', '.join(self.factory.protocols)))
else:
# assume wamp.2.json
serializerId = 'json'
serializerId = u'json'
else:
version, serializerId = parseSubprotocolIdentifier(response.protocol)
@ -218,7 +210,7 @@ class WampWebSocketFactory(object):
Base class for WAMP-over-WebSocket transport factory mixins.
"""
def __init__(self, factory, serializers=None, debug_wamp=False):
def __init__(self, factory, serializers=None):
"""
Ctor.
@ -230,11 +222,10 @@ class WampWebSocketFactory(object):
:class:`autobahn.wamp.interfaces.ISerializer`.
:type serializers: list
"""
assert(callable(factory))
if not callable(factory):
raise Exception(u'factory must be a callable')
self._factory = factory
self.debug_wamp = debug_wamp
if serializers is None:
serializers = []
@ -263,13 +254,13 @@ class WampWebSocketFactory(object):
pass
if not serializers:
raise Exception("could not import any WAMP serializers")
raise Exception(u'Could not import any WAMP serializer')
self._serializers = {}
for ser in serializers:
self._serializers[ser.SERIALIZER_ID] = ser
self._protocols = ["wamp.2.%s" % ser.SERIALIZER_ID for ser in serializers]
self._protocols = [u'wamp.2.{}'.format(ser.SERIALIZER_ID) for ser in serializers]
class WampWebSocketServerFactory(WampWebSocketFactory):

View File

@ -24,7 +24,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(MyComponent)

View File

@ -21,7 +21,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(MyComponent)

View File

@ -53,7 +53,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -61,7 +61,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -62,7 +62,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -66,7 +66,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -57,7 +57,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -76,7 +76,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -62,7 +62,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -63,7 +63,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -63,7 +63,7 @@ if __name__ == '__main__':
environ.get("AUTOBAHN_DEMO_ROUTER", u"wss://127.0.0.1:8083/ws"),
u"crossbardemo",
ssl=options, # try removing this, but still use self-signed cert
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -78,7 +78,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -71,7 +71,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -88,7 +88,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -77,7 +77,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -63,7 +63,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -96,7 +96,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -93,7 +93,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -64,7 +64,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -62,7 +62,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -71,7 +71,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -55,7 +55,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -105,7 +105,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Calculator)

View File

@ -26,7 +26,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(MyComponent)

View File

@ -22,7 +22,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(MyComponent)

View File

@ -53,7 +53,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -67,7 +67,7 @@ if __name__ == '__main__':
extra=dict(
max_events=5, # [A] pass in additional configuration
),
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -63,7 +63,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -70,7 +70,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -58,7 +58,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -72,7 +72,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -69,7 +69,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -66,7 +66,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -68,7 +68,7 @@ if __name__ == '__main__':
environ.get("AUTOBAHN_DEMO_ROUTER", u"wss://127.0.0.1:8083/ws"),
u"crossbardemo",
ssl=options, # try removing this, but still use self-signed cert
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -54,7 +54,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -74,7 +74,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -67,7 +67,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -87,7 +87,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -58,7 +58,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -90,7 +90,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -63,7 +63,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -95,7 +95,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -93,7 +93,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -64,7 +64,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -61,7 +61,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -62,7 +62,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -59,7 +59,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -60,7 +60,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -68,7 +68,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -57,7 +57,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)

View File

@ -57,7 +57,7 @@ if __name__ == '__main__':
runner = ApplicationRunner(
environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"),
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)