diff --git a/umbra/behaviors.py b/umbra/behaviors.py index fffc714..8c9733e 100644 --- a/umbra/behaviors.py +++ b/umbra/behaviors.py @@ -1,13 +1,19 @@ +# vim: set sw=4 et: + from json import dumps, load from time import sleep import os, re +import logging behaviors_file = os.path.sep.join(__file__.split(os.path.sep)[:-1] + ['behaviors.json']) -def execute(url, ws, command_id): +def execute(url, websock, command_id): + logger = logging.getLogger('behaviors') sleep(5) with open(behaviors_file) as js: behaviors = load(js) for behavior in behaviors: if re.match(behavior['site'], url): for script in behavior['scripts']: - ws.send(dumps(dict(method="Runtime.evaluate", params={"expression": script}, id=next(command_id)))) + msg = dumps(dict(method="Runtime.evaluate", params={"expression": script}, id=next(command_id))) + logger.debug('sending message to {}: {}'.format(websock, msg)) + websock.send(msg)