diff --git a/circusweb/circushttpd.py b/circusweb/circushttpd.py index 0da402b..086153b 100644 --- a/circusweb/circushttpd.py +++ b/circusweb/circushttpd.py @@ -13,7 +13,7 @@ from circusweb import logger, __version__ from circus.exc import CallError from circus.util import LOG_LEVELS, configure_logger -from circus.py3compat import string_types, b +from circus.py3compat import b from zmq.eventloop import ioloop from circusweb.util import AutoDiscovery, run_command from circusweb.session import (SessionManager, get_controller, @@ -57,12 +57,15 @@ 'session.auto': True } + def encode(s): return b64encode(s.encode('utf-8')).decode('utf-8') + def decode(s): return b64decode(s.encode('utf-8')).decode('utf-8') + def require_logged_user(func): @wraps(func) diff --git a/circusweb/namespace.py b/circusweb/namespace.py index 971725e..fb988eb 100644 --- a/circusweb/namespace.py +++ b/circusweb/namespace.py @@ -61,11 +61,13 @@ def consume_stats(cls, watcher, pid, stat, stat_endpoint): # requested them, send back the information. if 'sockets' in p.watchersWithPids and 'fd' in stat: p.emit('socket-stats-{fd}-{endpoint}'.format( - fd=stat['fd'], endpoint=stat_endpoint_b64.decode('utf-8')), + fd=stat['fd'], + endpoint=stat_endpoint_b64.decode('utf-8')), **stat) elif 'sockets' in p.watchers and 'addresses' in stat: p.emit('socket-stats-{endpoint}'.format( - endpoint=stat_endpoint_b64.decode('utf-8')), reads=stat['reads'], + endpoint=stat_endpoint_b64.decode('utf-8')), + reads=stat['reads'], adresses=stat['addresses']) else: available_watchers = p.watchers + p.watchersWithPids + \ @@ -75,12 +77,14 @@ def consume_stats(cls, watcher, pid, stat, stat_endpoint): if (watcher == 'circus' and stat.get('name', None) in available_watchers): p.emit('stats-{watcher}-{endpoint}'.format( - watcher=stat['name'], endpoint=stat_endpoint_b64.decode('utf-8')), + watcher=stat['name'], + endpoint=stat_endpoint_b64.decode('utf-8')), mem=stat['mem'], cpu=stat['cpu'], age=stat['age']) else: if pid is None: # means that it's the aggregation p.emit('stats-{watcher}-{endpoint}'.format( - watcher=watcher, endpoint=stat_endpoint_b64.decode('utf-8')), + watcher=watcher, + endpoint=stat_endpoint_b64.decode('utf-8')), mem=stat['mem'], cpu=stat['cpu'], age=stat['age']) else: @@ -88,7 +92,8 @@ def consume_stats(cls, watcher, pid, stat, stat_endpoint): p.emit( 'stats-{watcher}-{pid}-{endpoint}'.format( watcher=watcher, pid=pid, - endpoint=stat_endpoint_b64.decode('utf-8')), + endpoint=stat_endpoint_b64.decode( + 'utf-8')), mem=stat['mem'], cpu=stat['cpu'], age=stat['age'])