mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-04-19 23:35:54 -04:00
add a little logging
This commit is contained in:
parent
2368688fbe
commit
28282641f2
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user