Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
maparent committed Sep 21, 2017
1 parent b74f691 commit 66a100e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion circusweb/circushttpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions circusweb/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + \
Expand All @@ -75,20 +77,23 @@ 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:
if watcher in p.watchersWithPids:
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'])

0 comments on commit 66a100e

Please sign in to comment.