def json_decode(data): """ Decode the object with the configuable object hook. """ object_hook = get_class_or_func(app_settings.CLIENTSIGNAL_JSON_OBJECT_HOOK) return json.loads(data, object_hook=object_hook)
from clientsignal.redisconn import RedisSignalConnection from clientsignal.utils import get_class_or_func, get_routers class StatsSignalConnection(SimpleSignalConnection): pass class RedisStatsSignalConnection(RedisSignalConnection): pass stat_broadcast = Signal(providing_args=["stats"]) # StatsSignalConnection.broadcast('stat_broadcast', stat_broadcast) RedisStatsSignalConnection.broadcast('stat_broadcast', stat_broadcast) stat_connections = [get_class_or_func(c) for c in app_settings.CLIENTSIGNAL_STATS['connections']] host = "%s:%s" % (socket.gethostname(), settings.CLIENTSIGNAL_CURRENT_PORTS[0]) def _send_stats(): global stat_connections, host routers = get_routers() router_stats_dicts = [r.stats.dump() for r in routers if r._connection in stat_connections] router_stats = sum( (Counter(dict(x)) for x in router_stats_dicts), Counter()) clients_list = [(c.request.user.username, c.__class__.__name__) for c in StatsSignalConnection.clients
def json_encode(data): """ Encode the object with the configuable object hook. """ encoder_cls = get_class_or_func(app_settings.CLIENTSIGNAL_JSON_ENCODER) return json.dumps(data, separators=(',', ':'), cls=encoder_cls)