diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2018-04-29 10:44:33 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2018-05-04 16:00:05 +0200 |
commit | b30a44cfe9456deafc83e008f8501c391cd1e258 (patch) | |
tree | 91bd6a9f431b4155047e0f024fe9f5665766804e /contrib | |
parent | d15b498505dc0362fbd7e92bf7ba2945cad5a118 (diff) | |
download | crocoite-b30a44cfe9456deafc83e008f8501c391cd1e258.tar.gz crocoite-b30a44cfe9456deafc83e008f8501c391cd1e258.tar.bz2 crocoite-b30a44cfe9456deafc83e008f8501c391cd1e258.zip |
Move page archiving logic to SinglePageController
In preparation for recursive crawls.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/celerycrocoite.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/contrib/celerycrocoite.py b/contrib/celerycrocoite.py index c3a67ae..3d8c786 100644 --- a/contrib/celerycrocoite.py +++ b/contrib/celerycrocoite.py @@ -32,7 +32,8 @@ from threading import Thread from queue import Queue import queue -from crocoite import behavior, cli, defaults +from crocoite import behavior, task +from crocoite.controller import defaultSettings def prettyTimeDelta (seconds): """ @@ -125,14 +126,14 @@ def celeryWorker (bot, q): break action, trigger, args = item if action == 'ao': - handle = cli.archive.delay (**args) + handle = task.archive.delay (**args) j = jobs[handle.id] = {'handle': handle, 'trigger': trigger, 'args': args} # pretty-print a few selected args showargs = { - 'idleTimeout': prettyTimeDelta (args['idleTimeout']), - 'timeout': prettyTimeDelta (args['timeout']), - 'maxBodySize': prettyBytes (args['maxBodySize']), + 'idleTimeout': prettyTimeDelta (args['settings']['idleTimeout']), + 'timeout': prettyTimeDelta (args['settings']['timeout']), + 'maxBodySize': prettyBytes (args['settings']['maxBodySize']), } strargs = ', '.join (map (lambda x: '{}={}'.format (*x), showargs.items ())) bot.msg (trigger.sender, '{}: {} has been queued as {} with {}'.format (trigger.nick, args['url'], handle.id, strargs)) @@ -173,16 +174,12 @@ def archive (bot, trigger): return blacklistedBehavior = {'domSnapshot', 'screenshot'} - args = { - 'url': url, - 'output': None, - 'enabledBehaviorNames': list (behavior.availableNames-blacklistedBehavior), - 'browser': None, - 'logBuffer': defaults.logBuffer, - 'maxBodySize': defaults.maxBodySize, - 'idleTimeout': 10, - 'timeout': 1*60*60, # 1 hour - } + settings = dict (maxBodySize=defaultSettings.maxBodySize, + logBuffer=defaultSettings.logBuffer, idleTimeout=10, + timeout=1*60*60) + args = dict (url=url, + enabledBehaviorNames=list (behavior.availableNames-blacklistedBehavior), + settings=settings) q = bot.memory['crocoite']['q'] q.put_nowait (('ao', trigger, args)) |