diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2017-12-24 10:23:09 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2017-12-24 10:23:09 +0100 |
commit | d4951d1fe8be0941df9cafbfe57c21d26f66e8ee (patch) | |
tree | f24081e310a1bcbf1aea8ddc258d60050f012c0d /contrib | |
parent | fcb9ae93514d26085c8e0aebf2fc9b9c64a77453 (diff) | |
download | crocoite-d4951d1fe8be0941df9cafbfe57c21d26f66e8ee.tar.gz crocoite-d4951d1fe8be0941df9cafbfe57c21d26f66e8ee.tar.bz2 crocoite-d4951d1fe8be0941df9cafbfe57c21d26f66e8ee.zip |
Refactor behavior scripts
No functional changes, just cleanup. Replaces onload and onsnapshot
events. Move screen metric emulation, DOM snapshots and screenshots here
as well.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/celerycrocoite.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/contrib/celerycrocoite.py b/contrib/celerycrocoite.py index 83be7a6..1923629 100644 --- a/contrib/celerycrocoite.py +++ b/contrib/celerycrocoite.py @@ -28,8 +28,7 @@ from sopel.tools import Identifier, SopelMemory import celery from urllib.parse import urlsplit -import crocoite.cli -from crocoite import behavior +from crocoite import behavior, cli def prettyTimeDelta (seconds): """ @@ -82,22 +81,19 @@ def archive (bot, trigger): bot.reply ('{} is not a valid URL'.format (url)) return + blacklistedBehavior = {'domSnapshot', 'screenshot'} args = { 'url': url, 'output': None, - 'onload': ['scroll.js'] + behavior.getByUrl (url), - 'onsnapshot': [], + 'enabledBehaviorNames': list (behavior.availableNames-blacklistedBehavior), 'browser': None, 'logBuffer': 1000, 'maxBodySize': 10*1024*1024, 'idleTimeout': 10, - # 1 hour - 'timeout': 1*60*60, - 'domSnapshot': False, - 'screenshot': False, + 'timeout': 1*60*60, # 1 hour } - handle = crocoite.cli.archive.delay (**args) + handle = cli.archive.delay (**args) m = bot.memory['crocoite'] jobs = m['jobs'] # XXX: for some reason we cannot access the job’s state through handle, @@ -106,9 +102,10 @@ def archive (bot, trigger): # pretty-print a few selected args showargs = { - 'onload': ','.join (args['onload']), + 'behavior': ','.join (args['enabledBehaviorNames']), 'idleTimeout': prettyTimeDelta (args['idleTimeout']), 'timeout': prettyTimeDelta (args['timeout']), + 'maxBodySize': prettyBytes (args['maxBodySize']), } strargs = ', '.join (map (lambda x: '{}={}'.format (*x), showargs.items ())) bot.reply ('{} has been queued as {} with {}'.format (url, handle.id, strargs)) |